Win a copy of Penetration Testing Basics this week in the Security forum!
  • 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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic