I'm not sure where to ask this question.. here or at fusesource, or at
xstream. Quite a few libraries are responsible for marshalling the data and
I think it's xstream that actually needs the data format I'm talking about.
I've succeeded in sending a MapMessage from PHP to ActiveMQ via the stomp
protocol, as long as it only contains string datatypes. e.g.:
$body = array('map' => array('entry' => array(
array('string' => array('orders_id', '1234')),
array('string' => array('status', '4'))
)));
I do not know where the "map: { entry : [ ... etc" protocol is defined. I
believe it's expected in xstream. They don't appear on the receiving end in
the resulting MapMessage.
That map is received as a JMS MapMessage with orders_id => "1234" and status
=> "4". Great.
My problem is that as soon as I try to send a non-string value, the message
parsing fails. For example the most obvious change to make orders_id a long
instead of a string:
$body = array('map' => array('entry' => array(
array('long' => array('orders_id', 1234)),
array('string' => array('status', '4'))
)));
This sends ok from PHP, but barfs in the Java server:
"""""
Aug 7, 2011 10:18:55 PM
org.apache.activemq.transport.stomp.ProtocolConverter handleException
WARNING: Exception occurred processing:
SEND
amq-msg-type:MapMessage
transformation:jms-map-json
destination:/queue/integration/order_update
transformation-error:For input string: "orders_id" : For input string:
"orders_id"
---- Debugging information ----
message : For input string: "orders_id"
cause-exception : java.lang.NumberFormatException
cause-message : For input string: "orders_id"
class : java.util.HashMap
required-type : java.lang.Long
path : /map/entry/long
line number : -1
-------------------------------
{"map":{"entry":[{"long":["orders_id",1234],"...s","4"]}}]}}:
org.apache.activemq.transport.stomp.ProtocolException: Unsupported message
type 'MapMessage'
"""""
It is taking the string "orders_id" (NOT the value "1234") and trying to
call Long.parseLong("orders_id") which of course throws
NumberFormatException.
It seems that the processing of non-string fields no longer uses the "type:
{ key, value }" syntax.
Can anyone advise how to send non-string fields?
Just to mention, I believe I can take the data type identifiers seen in
com/thoughtworks/xstream/XStream.java .. and the
http://xstream.codehaus.org/converters.html reference shows a MapMessage
that looks like this:
<map>
<entry>
<string>apple</string>
<float>123.553</float>
</entry>
<entry>
<string>orange</string>
<float>55.4</float>
</entry>
</map>
Yet, simply changing 'string' to 'long' in my example seems to completely
change the expected format.
For now I can pass strings and convert them myself in the consumer but this
is clearly not the right solution in the long term.
Nick
--
View this message in context:
http://activemq.2283324.n4.nabble.com/Format-of-stomp-MapMessages-from-PHP-string-works-long-fails-tp3725070p3725070.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.