How to use JMS Message Transformation in ActiveMQ with Stomp/JSON

Phillip Whelan picture Phillip Whelan · Dec 31, 2008 · Viewed 8.4k times · Source

I am sending messages in JSON format to an ActiveMQ server. I am trying to use JMS Transformation to transform the JSON encoded object into a true Java Object in hopes of being able to use selectors on the data inside.

Here is a link to the documentation on Stomp and Message Transformation. Here is a link to a discussion on the patch where someone shows an example of a legal JSON object

The format of the JSON objects I am sending (in pretty print) are similar to this:

{
   "msg": {
      "flag1" : "value1",
      "flag2" : "value2"
   }
}

The messages arrive in the message queue, but with the transformation-error property set to 'msg : msg'.

Answer

Phillip Whelan picture Phillip Whelan · Dec 31, 2008

The only format accepted by the transformation jms-map-json or jms-object-json is a simple Map format, which in JSON is:

{"map" : 
  {"entry" : 
    [ 
      { "string1": [ "key1", "value1" ] },
      { "string2": [ "key2", "value2" ] }
    ]
  }
}

This is the same format shown in the discussion forum. This format represents a name/value pair map object in java.

Selectors are only usable on Properties and Headers.