Question

How would you implement a Content Enricher in WebSphere MQ using Java?

Given an existing input message is provided from a queue, here are some of my ideas, none of which satisfies me:

  1. Deep-clone the message object. Here is an explanation of how it could be done, but I can't find either clone() or serialize() methods for the javax.jms.Message class.
  2. Take the original message, set the additional properties using setXXXProperty() and send it forward. This throws an exception suggesting that the message is read-only.
  3. Create a new message, iterate over properties of the existing message and set them to the new message. getPropertyNames() can help to do this, but it says nothing about types of properties, so this information will be lost.
Was it helpful?

Solution

In short, IBM integration bus can do it in a message flow... But let me provide a WMQ Java answer also:

The message object that is received can be modified and sent back ... All you need to do is to read all the stuff you need from that message to some java object. For example you can use a Map for Properties. Then call clearProperties() and then set the modified properties. The issue of readonly goes away after calling clearProperties() (http://docs.oracle.com/javaee/5/api/javax/jms/Message.html#clearProperties%28%29)

So a mix of (2) and (3) can help in solving the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top