Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

MessageNotWriteableException - Need to write to JMS Message  RSS feed

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.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!