You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by mam1 <db...@novator.com> on 2009/03/15 03:38:05 UTC
camel-activemq java.util.Map over JMS
Hi.
I have a problem using camel activemq/jms components. I used to have a low
level socket communication using Java serialization. One of responses
contained a Serializable object that had a Map<Long, List<Long>> as its
member.
When I use camel activemq/jms the returned object contains a Map<String,
List<Long>>. Did anybody encounter similar problem? Is it possible to
configure jms/activemq to use Java serialization? Any ideas. BTW using
jms/activemq on both (client/server) sides of the channel results in
aforementioned behavior only on the client side. Server side accepts
Map<Long, List<Long>> parameter as expected.
Camel configuration is as following:
client:
<camel:camelContext trace="true">
<camel:proxy id="test_remoting_service_proxy"
serviceInterface="a.b.c.TestService"
serviceUrl="activemq:queue:test.serviceQueue?exchangePattern=InOut"/>
</camel:camelContext>
server:
<camel:camelContext>
<camel:export id="remoting_service"
serviceRef="test_remoting_service"
serviceInterface="a.b.c.TestService"
uri="activemq:queue:test.serviceQueue?exchangePattern=InOut"
/>
</camel:camelContext>
<beans:bean id="test_remoting_service" class="a.b.c.TestServiceImpl"/>
<broker:broker useJmx="false" persistent="false" brokerName="localhost"
cacheTempDestinations="true" enableStatistics="false">
<broker:transportConnectors>
<broker:transportConnector name="tcp"
uri="tcp://localhost:61616?trace=true"/>
</broker:transportConnectors>
</broker:broker>
<!-- configure the activemq component -->
<beans:bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<beans:property name="maxConcurrentConsumers" value="10"/>
<beans:property name="deliveryPersistent" value="true"/>
<beans:property name="concurrentConsumers" value="5"/>
<beans:property name="cacheLevelName" value="CACHE_CONNECTION"/>
<beans:property name="connectionFactory">
<beans:bean
class="org.apache.activemq.spring.ActiveMQConnectionFactory">
<beans:property name="brokerURL"
value="tcp://localhost:61616"/>
</beans:bean>
</beans:property>
</beans:bean>
Thanks in advance.
--
View this message in context: http://www.nabble.com/camel-activemq-java.util.Map-over-JMS-tp22519506p22519506.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
Re: camel-activemq java.util.Map over JMS
Posted by Claus Ibsen <cl...@gmail.com>.
On Sun, Mar 15, 2009 at 3:38 AM, mam1 <db...@novator.com> wrote:
>
> Hi.
>
> I have a problem using camel activemq/jms components. I used to have a low
> level socket communication using Java serialization. One of responses
> contained a Serializable object that had a Map<Long, List<Long>> as its
> member.
There is a ticket for RFE to allow setting which JMS message type should be used
http://issues.apache.org/activemq/browse/CAMEL-898
So you can force it to use serialization using ObjectMessage.
>
> When I use camel activemq/jms the returned object contains a Map<String,
> List<Long>>. Did anybody encounter similar problem? Is it possible to
> configure jms/activemq to use Java serialization? Any ideas. BTW using
> jms/activemq on both (client/server) sides of the channel results in
> aforementioned behavior only on the client side. Server side accepts
> Map<Long, List<Long>> parameter as expected.
So are you saying that when you use request-reply with JMS using Camel
on both client + server with AMQ, the response the client recieves is
suddenly with String in the Map?
You are welcome to put together a little .zip with a demo that
demonstrates this issue.
That would be great for investigation in the camel-jms codebase.
>
> Camel configuration is as following:
>
> client:
>
> <camel:camelContext trace="true">
> <camel:proxy id="test_remoting_service_proxy"
> serviceInterface="a.b.c.TestService"
>
> serviceUrl="activemq:queue:test.serviceQueue?exchangePattern=InOut"/>
> </camel:camelContext>
>
> server:
>
> <camel:camelContext>
> <camel:export id="remoting_service"
> serviceRef="test_remoting_service"
> serviceInterface="a.b.c.TestService"
> uri="activemq:queue:test.serviceQueue?exchangePattern=InOut"
> />
> </camel:camelContext>
>
> <beans:bean id="test_remoting_service" class="a.b.c.TestServiceImpl"/>
>
> <broker:broker useJmx="false" persistent="false" brokerName="localhost"
> cacheTempDestinations="true" enableStatistics="false">
> <broker:transportConnectors>
> <broker:transportConnector name="tcp"
> uri="tcp://localhost:61616?trace=true"/>
> </broker:transportConnectors>
> </broker:broker>
>
>
> <!-- configure the activemq component -->
> <beans:bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
> <beans:property name="maxConcurrentConsumers" value="10"/>
> <beans:property name="deliveryPersistent" value="true"/>
> <beans:property name="concurrentConsumers" value="5"/>
> <beans:property name="cacheLevelName" value="CACHE_CONNECTION"/>
> <beans:property name="connectionFactory">
> <beans:bean
> class="org.apache.activemq.spring.ActiveMQConnectionFactory">
> <beans:property name="brokerURL"
> value="tcp://localhost:61616"/>
> </beans:bean>
> </beans:property>
> </beans:bean>
>
> Thanks in advance.
>
> --
> View this message in context: http://www.nabble.com/camel-activemq-java.util.Map-over-JMS-tp22519506p22519506.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Re: camel-activemq java.util.Map over JMS
Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Mar 16, 2009 at 9:46 AM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> The problem is that you use Map as the type.
> And thus Camel wants to use javax.jms.MapMessage as the JMS type to
> send the message between the client/server.
>
> And the JMS MapMessage store all its keys as String objects
> http://java.sun.com/javaee/5/docs/api/javax/jms/MapMessage.html
>
> So you should send it as ObjectMessage instead.
>
> However as Camel select the type it want to use itself, then you
> cannot currently control the behavior.
> As a workaround you can use other types, eg a custom Object instead.
>
> The RFE to allow you to choose the type is this ticket:
> https://issues.apache.org/activemq/browse/CAMEL-898
I have just committed this into trunk. So it will be part of Camel 2.0
Then you should be able to send you Map as an Object and thus preserve
your keys as Long types.
>
>
>
>
> On Sun, Mar 15, 2009 at 2:29 PM, mam1 <db...@novator.com> wrote:
>>
>>
>>
>> mam1 wrote:
>>>
>>> Hi.
>>>
>>> I have a problem using camel activemq/jms components. I used to have a low
>>> level socket communication using Java serialization. One of responses
>>> contained a Serializable object that had a Map<Long, List<Long>> as its
>>> member.
>>>
>>> When I use camel activemq/jms the returned object contains a Map<String,
>>> List<Long>>. Did anybody encounter similar problem? Is it possible to
>>> configure jms/activemq to use Java serialization? Any ideas. BTW using
>>> jms/activemq on both (client/server) sides of the channel results in
>>> aforementioned behavior only on the client side. Server side accepts
>>> Map<Long, List<Long>> parameter as expected.
>>>
>>> Camel configuration is as following:
>>>
>>> client:
>>>
>>> <camel:camelContext trace="true">
>>> <camel:proxy id="test_remoting_service_proxy"
>>> serviceInterface="a.b.c.TestService"
>>>
>>> serviceUrl="activemq:queue:test.serviceQueue?exchangePattern=InOut"/>
>>> </camel:camelContext>
>>>
>>> server:
>>>
>>> <camel:camelContext>
>>> <camel:export id="remoting_service"
>>> serviceRef="test_remoting_service"
>>> serviceInterface="a.b.c.TestService"
>>>
>>> uri="activemq:queue:test.serviceQueue?exchangePattern=InOut" />
>>> </camel:camelContext>
>>>
>>> <beans:bean id="test_remoting_service" class="a.b.c.TestServiceImpl"/>
>>>
>>> <broker:broker useJmx="false" persistent="false"
>>> brokerName="localhost" cacheTempDestinations="true"
>>> enableStatistics="false">
>>> <broker:transportConnectors>
>>> <broker:transportConnector name="tcp"
>>> uri="tcp://localhost:61616?trace=true"/>
>>> </broker:transportConnectors>
>>> </broker:broker>
>>>
>>>
>>> <!-- configure the activemq component -->
>>> <beans:bean id="activemq"
>>> class="org.apache.activemq.camel.component.ActiveMQComponent">
>>> <beans:property name="maxConcurrentConsumers" value="10"/>
>>> <beans:property name="deliveryPersistent" value="true"/>
>>> <beans:property name="concurrentConsumers" value="5"/>
>>> <beans:property name="cacheLevelName" value="CACHE_CONNECTION"/>
>>> <beans:property name="connectionFactory">
>>> <beans:bean
>>> class="org.apache.activemq.spring.ActiveMQConnectionFactory">
>>> <beans:property name="brokerURL"
>>> value="tcp://localhost:61616"/>
>>> </beans:bean>
>>> </beans:property>
>>> </beans:bean>
>>>
>>> Thanks in advance.
>>>
>>>
>>
>> Thank you for quick reply.
>>
>> I am attaching a small demonstration zip. I forgot to mention that i was
>> using camel 1.6.0 and Spring 2.5.5
>> http://www.nabble.com/file/p22523230/camel-activemq-test.zip
>> camel-activemq-test.zip
>> --
>> View this message in context: http://www.nabble.com/camel-activemq-java.util.Map-over-JMS-tp22519506p22523230.html
>> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Re: camel-activemq java.util.Map over JMS
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
The problem is that you use Map as the type.
And thus Camel wants to use javax.jms.MapMessage as the JMS type to
send the message between the client/server.
And the JMS MapMessage store all its keys as String objects
http://java.sun.com/javaee/5/docs/api/javax/jms/MapMessage.html
So you should send it as ObjectMessage instead.
However as Camel select the type it want to use itself, then you
cannot currently control the behavior.
As a workaround you can use other types, eg a custom Object instead.
The RFE to allow you to choose the type is this ticket:
https://issues.apache.org/activemq/browse/CAMEL-898
On Sun, Mar 15, 2009 at 2:29 PM, mam1 <db...@novator.com> wrote:
>
>
>
> mam1 wrote:
>>
>> Hi.
>>
>> I have a problem using camel activemq/jms components. I used to have a low
>> level socket communication using Java serialization. One of responses
>> contained a Serializable object that had a Map<Long, List<Long>> as its
>> member.
>>
>> When I use camel activemq/jms the returned object contains a Map<String,
>> List<Long>>. Did anybody encounter similar problem? Is it possible to
>> configure jms/activemq to use Java serialization? Any ideas. BTW using
>> jms/activemq on both (client/server) sides of the channel results in
>> aforementioned behavior only on the client side. Server side accepts
>> Map<Long, List<Long>> parameter as expected.
>>
>> Camel configuration is as following:
>>
>> client:
>>
>> <camel:camelContext trace="true">
>> <camel:proxy id="test_remoting_service_proxy"
>> serviceInterface="a.b.c.TestService"
>>
>> serviceUrl="activemq:queue:test.serviceQueue?exchangePattern=InOut"/>
>> </camel:camelContext>
>>
>> server:
>>
>> <camel:camelContext>
>> <camel:export id="remoting_service"
>> serviceRef="test_remoting_service"
>> serviceInterface="a.b.c.TestService"
>>
>> uri="activemq:queue:test.serviceQueue?exchangePattern=InOut" />
>> </camel:camelContext>
>>
>> <beans:bean id="test_remoting_service" class="a.b.c.TestServiceImpl"/>
>>
>> <broker:broker useJmx="false" persistent="false"
>> brokerName="localhost" cacheTempDestinations="true"
>> enableStatistics="false">
>> <broker:transportConnectors>
>> <broker:transportConnector name="tcp"
>> uri="tcp://localhost:61616?trace=true"/>
>> </broker:transportConnectors>
>> </broker:broker>
>>
>>
>> <!-- configure the activemq component -->
>> <beans:bean id="activemq"
>> class="org.apache.activemq.camel.component.ActiveMQComponent">
>> <beans:property name="maxConcurrentConsumers" value="10"/>
>> <beans:property name="deliveryPersistent" value="true"/>
>> <beans:property name="concurrentConsumers" value="5"/>
>> <beans:property name="cacheLevelName" value="CACHE_CONNECTION"/>
>> <beans:property name="connectionFactory">
>> <beans:bean
>> class="org.apache.activemq.spring.ActiveMQConnectionFactory">
>> <beans:property name="brokerURL"
>> value="tcp://localhost:61616"/>
>> </beans:bean>
>> </beans:property>
>> </beans:bean>
>>
>> Thanks in advance.
>>
>>
>
> Thank you for quick reply.
>
> I am attaching a small demonstration zip. I forgot to mention that i was
> using camel 1.6.0 and Spring 2.5.5
> http://www.nabble.com/file/p22523230/camel-activemq-test.zip
> camel-activemq-test.zip
> --
> View this message in context: http://www.nabble.com/camel-activemq-java.util.Map-over-JMS-tp22519506p22523230.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Re: camel-activemq java.util.Map over JMS
Posted by mam1 <db...@novator.com>.
mam1 wrote:
>
> Hi.
>
> I have a problem using camel activemq/jms components. I used to have a low
> level socket communication using Java serialization. One of responses
> contained a Serializable object that had a Map<Long, List<Long>> as its
> member.
>
> When I use camel activemq/jms the returned object contains a Map<String,
> List<Long>>. Did anybody encounter similar problem? Is it possible to
> configure jms/activemq to use Java serialization? Any ideas. BTW using
> jms/activemq on both (client/server) sides of the channel results in
> aforementioned behavior only on the client side. Server side accepts
> Map<Long, List<Long>> parameter as expected.
>
> Camel configuration is as following:
>
> client:
>
> <camel:camelContext trace="true">
> <camel:proxy id="test_remoting_service_proxy"
> serviceInterface="a.b.c.TestService"
>
> serviceUrl="activemq:queue:test.serviceQueue?exchangePattern=InOut"/>
> </camel:camelContext>
>
> server:
>
> <camel:camelContext>
> <camel:export id="remoting_service"
> serviceRef="test_remoting_service"
> serviceInterface="a.b.c.TestService"
>
> uri="activemq:queue:test.serviceQueue?exchangePattern=InOut" />
> </camel:camelContext>
>
> <beans:bean id="test_remoting_service" class="a.b.c.TestServiceImpl"/>
>
> <broker:broker useJmx="false" persistent="false"
> brokerName="localhost" cacheTempDestinations="true"
> enableStatistics="false">
> <broker:transportConnectors>
> <broker:transportConnector name="tcp"
> uri="tcp://localhost:61616?trace=true"/>
> </broker:transportConnectors>
> </broker:broker>
>
>
> <!-- configure the activemq component -->
> <beans:bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
> <beans:property name="maxConcurrentConsumers" value="10"/>
> <beans:property name="deliveryPersistent" value="true"/>
> <beans:property name="concurrentConsumers" value="5"/>
> <beans:property name="cacheLevelName" value="CACHE_CONNECTION"/>
> <beans:property name="connectionFactory">
> <beans:bean
> class="org.apache.activemq.spring.ActiveMQConnectionFactory">
> <beans:property name="brokerURL"
> value="tcp://localhost:61616"/>
> </beans:bean>
> </beans:property>
> </beans:bean>
>
> Thanks in advance.
>
>
Thank you for quick reply.
I am attaching a small demonstration zip. I forgot to mention that i was
using camel 1.6.0 and Spring 2.5.5
http://www.nabble.com/file/p22523230/camel-activemq-test.zip
camel-activemq-test.zip
--
View this message in context: http://www.nabble.com/camel-activemq-java.util.Map-over-JMS-tp22519506p22523230.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
Re: camel-activemq java.util.Map over JMS
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You should check the updated wiki page how to do it
http://cwiki.apache.org/confluence/display/CAMEL/JMS
There is a new option: jmsMessageType. And see also the section:
Overriding or controlling the mapping
On Mon, Mar 16, 2009 at 4:31 PM, mam1 <db...@novator.com> wrote:
>
>
>
> mam1 wrote:
>>
>> Hi.
>>
>> I have a problem using camel activemq/jms components. I used to have a low
>> level socket communication using Java serialization. One of responses
>> contained a Serializable object that had a Map<Long, List<Long>> as its
>> member.
>>
>> When I use camel activemq/jms the returned object contains a Map<String,
>> List<Long>>. Did anybody encounter similar problem? Is it possible to
>> configure jms/activemq to use Java serialization? Any ideas. BTW using
>> jms/activemq on both (client/server) sides of the channel results in
>> aforementioned behavior only on the client side. Server side accepts
>> Map<Long, List<Long>> parameter as expected.
>>
>> Camel configuration is as following:
>>
>> client:
>>
>> <camel:camelContext trace="true">
>> <camel:proxy id="test_remoting_service_proxy"
>> serviceInterface="a.b.c.TestService"
>>
>> serviceUrl="activemq:queue:test.serviceQueue?exchangePattern=InOut"/>
>> </camel:camelContext>
>>
>> server:
>>
>> <camel:camelContext>
>> <camel:export id="remoting_service"
>> serviceRef="test_remoting_service"
>> serviceInterface="a.b.c.TestService"
>>
>> uri="activemq:queue:test.serviceQueue?exchangePattern=InOut" />
>> </camel:camelContext>
>>
>> <beans:bean id="test_remoting_service" class="a.b.c.TestServiceImpl"/>
>>
>> <broker:broker useJmx="false" persistent="false"
>> brokerName="localhost" cacheTempDestinations="true"
>> enableStatistics="false">
>> <broker:transportConnectors>
>> <broker:transportConnector name="tcp"
>> uri="tcp://localhost:61616?trace=true"/>
>> </broker:transportConnectors>
>> </broker:broker>
>>
>>
>> <!-- configure the activemq component -->
>> <beans:bean id="activemq"
>> class="org.apache.activemq.camel.component.ActiveMQComponent">
>> <beans:property name="maxConcurrentConsumers" value="10"/>
>> <beans:property name="deliveryPersistent" value="true"/>
>> <beans:property name="concurrentConsumers" value="5"/>
>> <beans:property name="cacheLevelName" value="CACHE_CONNECTION"/>
>> <beans:property name="connectionFactory">
>> <beans:bean
>> class="org.apache.activemq.spring.ActiveMQConnectionFactory">
>> <beans:property name="brokerURL"
>> value="tcp://localhost:61616"/>
>> </beans:bean>
>> </beans:property>
>> </beans:bean>
>>
>> Thanks in advance.
>>
>>
>
> Thank you very much.
>
> --
> View this message in context: http://www.nabble.com/camel-activemq-java.util.Map-over-JMS-tp22519506p22540668.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Re: camel-activemq java.util.Map over JMS
Posted by mam1 <db...@novator.com>.
mam1 wrote:
>
> Hi.
>
> I have a problem using camel activemq/jms components. I used to have a low
> level socket communication using Java serialization. One of responses
> contained a Serializable object that had a Map<Long, List<Long>> as its
> member.
>
> When I use camel activemq/jms the returned object contains a Map<String,
> List<Long>>. Did anybody encounter similar problem? Is it possible to
> configure jms/activemq to use Java serialization? Any ideas. BTW using
> jms/activemq on both (client/server) sides of the channel results in
> aforementioned behavior only on the client side. Server side accepts
> Map<Long, List<Long>> parameter as expected.
>
> Camel configuration is as following:
>
> client:
>
> <camel:camelContext trace="true">
> <camel:proxy id="test_remoting_service_proxy"
> serviceInterface="a.b.c.TestService"
>
> serviceUrl="activemq:queue:test.serviceQueue?exchangePattern=InOut"/>
> </camel:camelContext>
>
> server:
>
> <camel:camelContext>
> <camel:export id="remoting_service"
> serviceRef="test_remoting_service"
> serviceInterface="a.b.c.TestService"
>
> uri="activemq:queue:test.serviceQueue?exchangePattern=InOut" />
> </camel:camelContext>
>
> <beans:bean id="test_remoting_service" class="a.b.c.TestServiceImpl"/>
>
> <broker:broker useJmx="false" persistent="false"
> brokerName="localhost" cacheTempDestinations="true"
> enableStatistics="false">
> <broker:transportConnectors>
> <broker:transportConnector name="tcp"
> uri="tcp://localhost:61616?trace=true"/>
> </broker:transportConnectors>
> </broker:broker>
>
>
> <!-- configure the activemq component -->
> <beans:bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
> <beans:property name="maxConcurrentConsumers" value="10"/>
> <beans:property name="deliveryPersistent" value="true"/>
> <beans:property name="concurrentConsumers" value="5"/>
> <beans:property name="cacheLevelName" value="CACHE_CONNECTION"/>
> <beans:property name="connectionFactory">
> <beans:bean
> class="org.apache.activemq.spring.ActiveMQConnectionFactory">
> <beans:property name="brokerURL"
> value="tcp://localhost:61616"/>
> </beans:bean>
> </beans:property>
> </beans:bean>
>
> Thanks in advance.
>
>
Thank you very much.
--
View this message in context: http://www.nabble.com/camel-activemq-java.util.Map-over-JMS-tp22519506p22540668.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.