I have a requirement where I have to add and update message header in case
of message retry.

Here is my listener or consumer. My message is getting retried but I am
getting Exception when setting the header. Please advise the correct way of
doing this.

As per JMS spec and it says that Message Headers are never read-only.

javax.jms.MessageNotWriteableException: Message properties are read-only

public void onMessage(Message message) {
    if (message != null && message instanceof TextMessage) {
        TextMessage textMessage = (TextMessage) message;
        try {
            String input = textMessage.getText();
            throw new Exception();
        } catch (Throwable t) {
            t.printStackTrace();
            try {
                message.setStringProperty("retryable","YES");
            } catch (JMSException e) {
                e.printStackTrace();
            }
            throw new RuntimeException(t);
        }
    }
}



--
View this message in context: 
http://activemq.2283324.n4.nabble.com/Message-Header-Update-AMQ-during-Retry-tp4694533.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to