将自定义对象绑定到 JMS MapMessage
是否有一种标准方法可以将我自己的自定义对象添加到 Map,然后将其正确编组到 MapMessage 中?目前我收到无效的对象类型消息。我注意到WebSphere有一个解决方案,但我正在寻找一些不绑定到特定AS的东西,如果没有这样的方法,也许JBoss支持的东西可以工作。
如何在 WebSphere 中执行此操作: http://publib.boulder.ibm.com/infocenter/dmndhelp/v6rxmx/index.jsp?topic=/com.ibm.websphere.wesb.doc/ref/rwesb_jmscustombindings.html
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. I noticed that WebSphere has a solution but I am looking for something that is not bound to a particular AS, if there is no such method, maybe something supported by JBoss would work.
How to do it in WebSphere:
http://publib.boulder.ibm.com/infocenter/dmndhelp/v6rxmx/index.jsp?topic=/com.ibm.websphere.wesb.doc/ref/rwesb_jmscustombindings.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
JMS 映射消息的映射仅支持基元和字符串(及其数组)作为值。
来自 javadoc:
您最好使用 ObjectMessage 并将序列化对象写入映射然后将地图作为 ObjectMessage 的有效负载发送。这样,您仍然可以拥有名称/值映射访问样式,但不受类型限制。
A JMS map message's map only supports primitives and strings (and their arrays) as values.
From the javadoc:
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.
使用
JsmTemplate
在 Spring (2.5, 3.1) 中,如果您想通过
jmsTemplate.convertAndSend()
发送Map
,其中 Map 包含非原始对象,您可以将 Map 转换为Serialized
并调用send(MessageCreator)
。这边走:这样 jmsTemplate 将与可序列化的映射一起使用,并通过线路发送
ObjectMessage
。请注意,使用消息的侦听器必须能够读取 ObjectMessage,然后再次将其转换为 Map。请注意,线路的两端都必须有相应的类,当然,Map 内的对象必须是可序列化的!
With
JsmTemplate
in Spring (2.5, 3.1), if you want to send aMap
throughjmsTemplate.convertAndSend()
where the Map contains a non-primitive object, you could cast the Map asSerializable
and callsend(MessageCreator)
. This way:This way jmsTemplate will work with the Map as Serializable and will send an
ObjectMessage
over the wire.Note that the listener consuming messages will have to be able to read the ObjectMessage and then cast it as Map again. Be aware that you have to had the corresponding classes at both sides of the wire, and of course, the objects inside the Map has to be Serializable!