You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Skanda <sh...@gmail.com> on 2015/04/08 19:12:34 UTC

Message Header Update AMQ during Retry


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.

Re: Message Header Update AMQ during Retry

Posted by "nix.huang" <ja...@hotmail.com>.
the default ACKNOWLEDGE mode is AUTO_ACKNOWLEDGE.when receive() returns the
message acknowledged,
you can use CLIENT_ACKNOWLEDGE mode alternatively.
for example:
session = connection.createSession(true, Session.CLIENT_ACKNOWLEDGE);
....
Message msg = ...
message.acknowledge();



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