bind a custom object to a JMS MapMessage

后端 未结 2 473
深忆病人
深忆病人 2021-01-14 10:48

Is there a standard way for me to add my own custom object to a Map and then have it properly marshalled in a MapMessage? Currently I get the Invalid Object Type message.

2条回答
  •  鱼传尺愫
    2021-01-14 11:13

    A JMS map message's map only supports primitives and strings (and their arrays) as values. From the javadoc:

    The names are String objects, and the values are primitive data types in the Java programming language.

    You would be better off using an ObjectMessage and write your serialized objects to a map and then send the map as the payload of the ObjectMessage. That way, you can still have the name/value map access style but without the limitation of types.

提交回复
热议问题