Sending Map<String,CustomObject>

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Sending Map<String,CustomObject>

Joe White-3
I would like to send a Map<String,MyCustomObject> through Camel using
ActiveMQ JMS , but Camel inspects the body of the message and notes that
it is an instance of Map (JMSBinding.java line 316 in camel 1.5) wraps
it up in a MapMessage and then sends it along.

 

The issue is that the MapMessage spec will only handle Primitives as the
values in a MapMessage and  ultimately this results in an NPE in
activeMq (below). I need to send a complex object as the value. It would
meet my needs if I could avoid the Camel interpretation of my payload
and simply send along an Object message. Is there any way to force the
use of an Object message and just send the Map as an object?

 

Also, I think that checking instanceof Map to try and build a Map
message is a defect as it should check that the values in the Map are
primitives.

 

If anybody knows a way around the MapMessage wrapper code to send a Map
that would be very helpful. I'm using Camel 1.5 and ActiveMQ 5.2

 

Thanks

Joe

 

 

 

java.lang.NullPointerException

      at
org.apache.activemq.util.MarshallingSupport.marshalPrimitiveMap(Marshall
ingSupport.java:63)

      at
org.apache.activemq.util.MarshallingSupport.marshalPrimitive(Marshalling
Support.java:142)

      at
org.apache.activemq.util.MarshallingSupport.marshalPrimitiveMap(Marshall
ingSupport.java:67)

      at
org.apache.activemq.command.ActiveMQMapMessage.storeContent(ActiveMQMapM
essage.java:132)

      at
org.apache.activemq.command.ActiveMQMapMessage.copy(ActiveMQMapMessage.j
ava:111)

      at
org.apache.activemq.command.ActiveMQMapMessage.copy(ActiveMQMapMessage.j
ava:106)

      at
org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1634)

      at
org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer
.java:227)

      at
org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageP
roducerSupport.java:269)

      at
org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:594)

      at
org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.doSend(
JmsConfiguration.java:219)

      at
org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate$1.doInJ
ms(JmsConfiguration.java:184)

      at
org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:471)

      at
org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(Jm
sConfiguration.java:173)

      at
org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:172)

      at
com.recondotech.service.common.BaseService.register(BaseService.java:118
)

Reply | Threaded
Open this post in threaded view
|

Re: Sending Map<String,CustomObject>

Claus Ibsen-2
On Mon, Apr 6, 2009 at 7:01 PM, Joe White <[hidden email]> wrote:

> I would like to send a Map<String,MyCustomObject> through Camel using
> ActiveMQ JMS , but Camel inspects the body of the message and notes that
> it is an instance of Map (JMSBinding.java line 316 in camel 1.5) wraps
> it up in a MapMessage and then sends it along.
>
>
>
> The issue is that the MapMessage spec will only handle Primitives as the
> values in a MapMessage and  ultimately this results in an NPE in
> activeMq (below). I need to send a complex object as the value. It would
> meet my needs if I could avoid the Camel interpretation of my payload
> and simply send along an Object message. Is there any way to force the
> use of an Object message and just send the Map as an object?
>
>
>
> Also, I think that checking instanceof Map to try and build a Map
> message is a defect as it should check that the values in the Map are
> primitives.
>
>
>
> If anybody knows a way around the MapMessage wrapper code to send a Map
> that would be very helpful. I'm using Camel 1.5 and ActiveMQ 5.2
In Camel 2.0 you can set which jmsMessageType to use, eg forcing it to
use Object.

The only workaround in Camel 1.x is to wrap it in some other form of
object type (non Map)
And then unwrap it on the consumer side


>
>
>
> Thanks
>
> Joe
>
>
>
>
>
>
>
> java.lang.NullPointerException
>
>      at
> org.apache.activemq.util.MarshallingSupport.marshalPrimitiveMap(Marshall
> ingSupport.java:63)
>
>      at
> org.apache.activemq.util.MarshallingSupport.marshalPrimitive(Marshalling
> Support.java:142)
>
>      at
> org.apache.activemq.util.MarshallingSupport.marshalPrimitiveMap(Marshall
> ingSupport.java:67)
>
>      at
> org.apache.activemq.command.ActiveMQMapMessage.storeContent(ActiveMQMapM
> essage.java:132)
>
>      at
> org.apache.activemq.command.ActiveMQMapMessage.copy(ActiveMQMapMessage.j
> ava:111)
>
>      at
> org.apache.activemq.command.ActiveMQMapMessage.copy(ActiveMQMapMessage.j
> ava:106)
>
>      at
> org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1634)
>
>      at
> org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer
> .java:227)
>
>      at
> org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageP
> roducerSupport.java:269)
>
>      at
> org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:594)
>
>      at
> org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.doSend(
> JmsConfiguration.java:219)
>
>      at
> org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate$1.doInJ
> ms(JmsConfiguration.java:184)
>
>      at
> org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:471)
>
>      at
> org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(Jm
> sConfiguration.java:173)
>
>      at
> org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:172)
>
>      at
> com.recondotech.service.common.BaseService.register(BaseService.java:118
> )
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration