Standard pattern is:
- App1 sends a message to App2
- App2 stores the JMSMsgID (say 123) and completes the processing
- App2 generates response for App1 and sets above JMSMsgID (123) as JMSCorrelID
- App1 receives the response, using the JMSCorrelID it matches with the original request
From Java EE doc:
void setJMSMessageID(String id) throws JMSException
Sets the message ID.
JMS providers set this field when a message is sent. This method can be used to change the value for a message that has been received.
I am not sure what purpose it solves to change message ID after a message is received. Key point to note is that JMS provider shall set/override this value when the message is published. Which means even if you try to override by calling this method, the value will be lost!!
On Websphere default messaging, we can set message ID to any value, but on JBoss messaging it mandates that you prefix the value with ID: as per spec :-) Anyways the value gets lost. So how to use this property??
As highlighted above message ID is set after the message is sent/published. We can get the same using getJMSMessageID method on Message. We need to store this to link with the response we receive later.
So far good. Then later I got to know from our client that he is sending his own message ID, back to square one thinking how is this possible? Silly me...this restriction is imposed by JMS API !! so my client must be doing this using different API. For IBM MQ, we have a Java API, which is seperate from JMS API. It also offers API for C as well. When you use this API, this restriction does not apply. We can set the message ID value to whatever we want. The doc of this API confirms this, below is the extract:
No comments:
Post a Comment