You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Robert Thullner <rt...@gmx.at> on 2008/03/22 16:04:51 UTC

Camel transports in ServiceMix

Hi

I use the Camel JBI component in ServiceMix for routing between endpoints of
service-units. But I would also like to put JMS messages directly to a JMS
queue with Camel, without having to route a message to a JMS provider
service unit which then sends the message to the queue. 

Can this be achieved by the Camel JBI component. If yes, could you give me
an example, because I did not get it working until now. 

Thanks
Robert
-- 
View this message in context: http://www.nabble.com/Camel-transports-in-ServiceMix-tp16222771s22882p16222771.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel transports in ServiceMix

Posted by Robert Thullner <rt...@gmx.at>.
I now tried the combination of both convertBodyTo() methods and it works. I
receive an ActiveMQTextMessage now.

This route works fine:

from("jbi:endpoint:http://eip.splitter.servicemix/camelRouter/endpoint")
.to("log:jms")
.convertBodyTo(DOMSource.class)                                             
.convertBodyTo(String.class)    
.to("activemq:queue:camel.train.plan.queue.neusiedlsee");

Thank you for your support

Best regards,
Robert



Gert Vanthienen wrote:
> 
> Robert,
> 
> Have you tried with the two convertBodyTo() statements as shown in the 
> tutorial? I'm not sure Camel 1.2.0 (which is shipped with ServiceMix 
> 3.2.1) support direct conversion from a JBI NormalizedMessage to String.
> 
> Gert
> 
> 

-- 
View this message in context: http://www.nabble.com/Camel-transports-in-ServiceMix-tp16222771s22882p16282904.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel transports in ServiceMix

Posted by Gert Vanthienen <ge...@skynet.be>.
Robert,

Have you tried with the two convertBodyTo() statements as shown in the 
tutorial? I'm not sure Camel 1.2.0 (which is shipped with ServiceMix 
3.2.1) support direct conversion from a JBI NormalizedMessage to String.

Gert

Robert Thullner wrote:
> When  I use to("log:jms") in the Camel route, the following line is printed
> by ServiceMix:
> INFO  - jms - Exchange[JbiMessage:
> org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@67aae{properties:
> {}}]
>
> I think the following happens. A JMS message is sent to the JMS consumer
> service-unit. The message is marhalled to a NormalizedMessage and then
> passed to Camel service-unit which sends a NormalizedMessage to a JMS queue
> but does no marhalling to an ActiveMQTextMessage on the message. 
> What do you think about that?
>
> I also tried the convertBodyTo(String.class) statement, but this does not
> have any effect. 
>
> I use the activemq jar files which are included in the ServiceMix
> distribution in my message producers and receivers, so the message format
> should be the same. 
>
> Greetings,
> Robert
>
>
> Gert Vanthienen wrote:
>   
>> Robert,
>>
>> There probably is a difference in the data format being using by the 
>> Camel and ServiceMix JMS receiver endpoints.  Could you add a 
>> .to("log:jms") or something similar to determine what the data format of 
>> the message body is?  You can also try explicitly converting the body 
>> (e.g. using .convertBodyTo(String.class)) in your route just before you 
>> send it to ActiveMQ.
>>
>> Gert
>>
>>
>>
>>     
>
>   


Re: Camel transports in ServiceMix

Posted by Gert Vanthienen <ge...@skynet.be>.
Robert,

That's exactly what's happening.  If you take a look at 
http://servicemix.apache.org/34-exchanging-messages-with-other-jbi-services.html, 
that shows you how you can use convertBodyTo() to change the data 
representation before sending it to your ActiveMQ queue.

Gert

Robert Thullner wrote:
> When  I use to("log:jms") in the Camel route, the following line is printed
> by ServiceMix:
> INFO  - jms - Exchange[JbiMessage:
> org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@67aae{properties:
> {}}]
>
> I think the following happens. A JMS message is sent to the JMS consumer
> service-unit. The message is marhalled to a NormalizedMessage and then
> passed to Camel service-unit which sends a NormalizedMessage to a JMS queue
> but does no marhalling on the message. 
> What do you think about that?
>
> I use the activemq jar files which are included in the ServiceMix
> distribution in my message producers and receivers, so the message format
> should be the same. 
>
> Greetings,
> Robert
>
>
> Gert Vanthienen wrote:
>   
>> Robert,
>>
>> There probably is a difference in the data format being using by the 
>> Camel and ServiceMix JMS receiver endpoints.  Could you add a 
>> .to("log:jms") or something similar to determine what the data format of 
>> the message body is?  You can also try explicitly converting the body 
>> (e.g. using .convertBodyTo(String.class)) in your route just before you 
>> send it to ActiveMQ.
>>
>> Gert
>>
>>
>>
>>     
>
>   


Re: Camel transports in ServiceMix

Posted by Robert Thullner <rt...@gmx.at>.

When  I use to("log:jms") in the Camel route, the following line is printed
by ServiceMix:
INFO  - jms - Exchange[JbiMessage:
org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@67aae{properties:
{}}]

I think the following happens. A JMS message is sent to the JMS consumer
service-unit. The message is marhalled to a NormalizedMessage and then
passed to Camel service-unit which sends a NormalizedMessage to a JMS queue
but does no marhalling on the message. 
What do you think about that?

I use the activemq jar files which are included in the ServiceMix
distribution in my message producers and receivers, so the message format
should be the same. 

Greetings,
Robert


Gert Vanthienen wrote:
> 
> Robert,
> 
> There probably is a difference in the data format being using by the 
> Camel and ServiceMix JMS receiver endpoints.  Could you add a 
> .to("log:jms") or something similar to determine what the data format of 
> the message body is?  You can also try explicitly converting the body 
> (e.g. using .convertBodyTo(String.class)) in your route just before you 
> send it to ActiveMQ.
> 
> Gert
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Camel-transports-in-ServiceMix-tp16222771s22882p16274450.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel transports in ServiceMix

Posted by Gert Vanthienen <ge...@skynet.be>.
Robert,

There probably is a difference in the data format being using by the 
Camel and ServiceMix JMS receiver endpoints.  Could you add a 
.to("log:jms") or something similar to determine what the data format of 
the message body is?  You can also try explicitly converting the body 
(e.g. using .convertBodyTo(String.class)) in your route just before you 
send it to ActiveMQ.

Gert

Robert Thullner wrote:
>
> James.Strachan wrote:
>   
>>
>> Could you post the code you're using to send the message please?
>> Sounds like something is a bit strange.
>>
>> FWIW when using ActiveMQ a TextMessage should result in an
>> ActiveMQTextMessage being sent. If an ActiveMQMessage is received then
>> that usually indicates an empty body
>>
>>
>>     
>
> Here is what I do:
>
> This is how I send my message:
>
> TextMessage statusInformationMessage = session.createTextMessage();
> statusInformationMessage.setText(generateFlightPlan().toString());
> statusInformationMessage.setStringProperty("test", "test");
> statusInformationMessage.setJMSCorrelationID(""+System.currentTimeMillis());
> producer.send(statusInformationMessage);
>
>
> In ServiceMix I have configured a consumer endpoint which looks like this
>
> <jms:endpoint service="splitter:receiveTravelplan"
>    endpoint="endpoint"
>    targetService="splitter:camelRouter"
>    role="consumer" 
>    destinationStyle="queue"
>    jmsProviderDestinationName="camel.train.plan.queue"
>    defaultMep="http://www.w3.org/2004/08/wsdl/in-only"
>    connectionFactory="#connectionFactory" />
>
> At last my Camel route looks like this:
> from("jbi:endpoint:http://eip.splitter.servicemix/camelRouter/endpoint")
> .to("activemq:queue:camel.train.plan.queue.neusiedlsee");
>
>
> Now I receive a message of type ActiveMQMessage in my JMS receiver. 
>
> I have made some more interesting observations:
> When I do not use the JMS consumer service unit and also use the Camel JBI
> to directly receive message, everything works fine. So when I use this camel
> route in ServiceMix everything works fine and I receive an
> ActiveMQTextMessage:
> from("activemq:queue:camel.train.plan.queue")
> .to("activemq:queue:camel.train.plan.queue.neusiedlsee");
>
> My second observations is that: When I use the new JMS endpoints of
> ServiceMix like <jms:consumer ...> for receiving JMS messages, I receive an
> ActiveMQObjectMessage at my final receiver. 
>
> However I think, this all is a ServiceMix isssue and not a Camel issue, so
> perhaps it is placed now on the wrong list. 
>
> Best regards,
> Robert
>   


Re: Camel transports in ServiceMix

Posted by Robert Thullner <rt...@gmx.at>.


James.Strachan wrote:
> 
> 
> 
> Could you post the code you're using to send the message please?
> Sounds like something is a bit strange.
> 
> FWIW when using ActiveMQ a TextMessage should result in an
> ActiveMQTextMessage being sent. If an ActiveMQMessage is received then
> that usually indicates an empty body
> 
> 

Here is what I do:

This is how I send my message:

TextMessage statusInformationMessage = session.createTextMessage();
statusInformationMessage.setText(generateFlightPlan().toString());
statusInformationMessage.setStringProperty("test", "test");
statusInformationMessage.setJMSCorrelationID(""+System.currentTimeMillis());
producer.send(statusInformationMessage);


In ServiceMix I have configured a consumer endpoint which looks like this

<jms:endpoint service="splitter:receiveTravelplan"
   endpoint="endpoint"
   targetService="splitter:camelRouter"
   role="consumer" 
   destinationStyle="queue"
   jmsProviderDestinationName="camel.train.plan.queue"
   defaultMep="http://www.w3.org/2004/08/wsdl/in-only"
   connectionFactory="#connectionFactory" />

At last my Camel route looks like this:
from("jbi:endpoint:http://eip.splitter.servicemix/camelRouter/endpoint")
.to("activemq:queue:camel.train.plan.queue.neusiedlsee");


Now I receive a message of type ActiveMQMessage in my JMS receiver. 

I have made some more interesting observations:
When I do not use the JMS consumer service unit and also use the Camel JBI
to directly receive message, everything works fine. So when I use this camel
route in ServiceMix everything works fine and I receive an
ActiveMQTextMessage:
from("activemq:queue:camel.train.plan.queue")
.to("activemq:queue:camel.train.plan.queue.neusiedlsee");

My second observations is that: When I use the new JMS endpoints of
ServiceMix like <jms:consumer ...> for receiving JMS messages, I receive an
ActiveMQObjectMessage at my final receiver. 

However I think, this all is a ServiceMix isssue and not a Camel issue, so
perhaps it is placed now on the wrong list. 

Best regards,
Robert
-- 
View this message in context: http://www.nabble.com/Camel-transports-in-ServiceMix-tp16222771s22882p16273148.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel transports in ServiceMix

Posted by James Strachan <ja...@gmail.com>.
On 23/03/2008, Robert Thullner <rt...@gmx.at> wrote:
>
>  Thanks for the reply, I made it working to send messages in the Camel SU
>  directly to a JMS queue and not to a SU. However my problem now is the
>  following:
>
>  I send JMS TextMessage which contains XML content. When my application
>  receives the message it is not a TextMessage anymore, but an
>  ActiveMQMessage. How can I get the XML content out of the ActiveMQMessage. I
>  tried the getContent() method (see below) but this always returns null. I
>  did not find any example for that.
>  ByteSequence bs = ((ActiveMQMessage)message).getContent();
>
>  Furthermore the JMSCorrelationId and all other properties are also null when
>  I retrieve it from the incoming message.

Could you post the code you're using to send the message please?
Sounds like something is a bit strange.

FWIW when using ActiveMQ a TextMessage should result in an
ActiveMQTextMessage being sent. If an ActiveMQMessage is received then
that usually indicates an empty body

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Camel transports in ServiceMix

Posted by Robert Thullner <rt...@gmx.at>.
Thanks for the reply, I made it working to send messages in the Camel SU
directly to a JMS queue and not to a SU. However my problem now is the
following:

I send JMS TextMessage which contains XML content. When my application
receives the message it is not a TextMessage anymore, but an
ActiveMQMessage. How can I get the XML content out of the ActiveMQMessage. I
tried the getContent() method (see below) but this always returns null. I
did not find any example for that. 
ByteSequence bs = ((ActiveMQMessage)message).getContent();

Furthermore the JMSCorrelationId and all other properties are also null when
I retrieve it from the incoming message. 

Best regards,
Robert



Chris Custine (Apache) wrote:
> 
> This should definitely work.  Please post some log output or some other
> information describing your issue so that we can help you.  Just as an
> obvious suggestion, make sure that you have the camel-jms jar file and the
> jar file of your JMS provider in your SU.
> 
> Chris
> 
> 

-- 
View this message in context: http://www.nabble.com/Camel-transports-in-ServiceMix-tp16222771s22882p16240726.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel transports in ServiceMix

Posted by Chris Custine <cc...@apache.org>.
This should definitely work.  Please post some log output or some other
information describing your issue so that we can help you.  Just as an
obvious suggestion, make sure that you have the camel-jms jar file and the
jar file of your JMS provider in your SU.

Chris

On Sat, Mar 22, 2008 at 9:04 AM, Robert Thullner <rt...@gmx.at> wrote:

>
> Hi
>
> I use the Camel JBI component in ServiceMix for routing between endpoints
> of
> service-units. But I would also like to put JMS messages directly to a JMS
> queue with Camel, without having to route a message to a JMS provider
> service unit which then sends the message to the queue.
>
> Can this be achieved by the Camel JBI component. If yes, could you give me
> an example, because I did not get it working until now.
>
> Thanks
> Robert
> --
> View this message in context:
> http://www.nabble.com/Camel-transports-in-ServiceMix-tp16222771s22882p16222771.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>