File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Strip JMS Headers from TextMessage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Strip JMS Headers from TextMessage" Watch "Strip JMS Headers from TextMessage" New topic

Strip JMS Headers from TextMessage

Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
You get TextMessage inside onMessage(..) method of Message Driven Bean.

When you do toString() on the textMessage instance, at first, you get JMS headers. After that only, you get your actula message that you put in the queue.

I can always strip out the headers by String parsing. However, is there an elegant way (WebSphere Server Configuration, or MQ configuration, or JMS API) to remove JMS headers from the message so that I only get the actual message and no header?

Hearder is like:
JMS Message class: jms_text
JMSType: null
JMSDeliveryMode: 1
JMSExpiration: 0
JMSPriority: 0
JMSMessageID: ID:414d5120514d444f43444141202020204377126c20001a01
JMSTimestamp: 1132259105100
JMSDestination: null
JMSReplyTo: null
JMSRedelivered: false
My actual message starts here after all the above headers ........
Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
Is getText() the only alternative?
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Hi Sam,

Using MapMessage(s) rather than TextMessage(s) might help:


I think, therefore I exist -- Rene Descartes
I agree. Here's the link:
subject: Strip JMS Headers from TextMessage
It's not a secret anymore!