2
votes

I am writing a Java batch which is listening messages from a queue (Oracle AQ) and sending them to another queue (Tibco EMS), where they are processed by a Tibco process (BW).

The problem is that the Oracle AQ driver automatically add some properties to messages (JMSXGroupID, JMSXGroupSeq) which cause errors when they are processed by Tibco process because they have bad values : JMSXGroupSeq should be an int but is set to null. Tibco falls into error when trying to parse message properties...

So I would like to remove only these 2 properties from all messages but it seems that the jms api only offers a clearProperties() method but no single property remove method (I'm using ths javax.jms.Message interface).

For now, I can see two solutions :

  1. set a correct value to these 2 properties, as I'm assuming they will not be used further by Tibco

  2. read all properties and reconstruct the messages without the 2 which cause problem. But this approach is very ugly...

Does anyone have any other solution?

2

2 Answers

10
votes

It is not possible to edit/clear some properties. We need to call clearProperties method as described here to get write access :

Once a message is produced (sent), its properties become read-only; the properties cannot be changed. While consumers can read the properties using the property accessor methods (getProperty( )), they cannot modify the properties using any of the mutator methods (setProperty( )). If the consumer attempts to set a property, the mutator method throws a javax.jms.MessageNotWriteableException.

Once a message is received, the only way its properties can be changed is by clearing out all the properties using the clearProperties( ) method. This removes all the properties from the message so that new ones can be added. Individual properties cannot be modified or removed once a message is sent.

0
votes

There will be a function public void removeProperty(String name) in the concrete class implementation of javax.jms.Message interface. This classs is provider specific(Tibco EMS in your case). As it is closed source I cannot be for sure about the existence of that function. But it is present in HornetQ.It can be used to reset particular header property.

Other than that I thing option 1 is the best. You set it to some non null value acceptable by Message header parser of Tibco EMS.