• Post Reply Bookmark Topic Watch Topic
  • New Topic

MessageNotWriteableException - Need to write to JMS Message

 
Sam Gehouse
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get read-only JMSMessage in onMessage(TextMessage msg) method of Message Driven bean.

I process that message. However, if an Exception is thrown, I am required to append error info to the same textMessage(same textMessage that came to me as argument of onMessage method).

However this textMessage is read only. I cannot write to it using
textMsg.setStringProperty("error", "Error description");

I want to keep the original header info and message from msg that came in onMessage().

I used code like following with no luck:
TextMessage m = queueSession.createTextMessage();
m = msg; // msg is from onMessage() argument
m.setStringProperty("error", "Error description");

How can I set error condition to a message (could be a new message all together, if not the same message that comes from onMessage()) using API?

I need a message that is writeable and would typically like to copy all info from msg to the new writeable textmessage.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!