camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Senthilkumar Arumugam <senthilkumar...@gmail.com>
Subject Re: Problem with consuming different types of message from same endpoint
Date Mon, 23 Aug 2010 13:32:01 GMT
Hi Willem,

Thank you for your response. I could add filters and get it working for me.

I have had to configure as below mentioned, to get it working for me.

<filter>
  <simple>${body.args[0]} is Foo</simple>
  <bean ref="foo" method="save" />
</filter>

The filter holds false for Exchange when I try checking the ${body} is Foo.
It would be great to get directed, if there were anything incorrect I had
done.

Thanks,
SK

On Sun, Aug 22, 2010 at 12:51 PM, Willem Jiang <willem.jiang@gmail.com>wrote:

> I don't know why you have two bean's saveOne method to call.
> Do you want to call foo.saveOne if the message body is the instance of Foo
> and call bar.saveOne if the message body is the instance of Bar?
>
> If so you can use the Content Base Router[1] to do it, and using Simple[2]
> language to check the message body like this.
>
>
> <camel:route>
>   <camel:from uri="queue:one" />
>   <camel:transacted ref="required" />
>   <camel:choice>
>      <camel:when>
>         <camel:simple>${body} is 'FOO'</camel:simple>
>
>         <camel:bean ref="foo" method="saveOne" />
>      </camel:when>
>      <camel:when>
>         <camel:simple>${body} is 'BAR'</camel:simple>
>
>         <camel:bean ref="bar" method="saveOne" />
>      </camel:when>
>  </camel:route>
>
> [1]http://camel.apache.org/content-based-router.html
> [2]http://camel.apache.org/simple.html
>
> Willem
>
> senthil.arumugam wrote:
>
>> Hi,
>>
>> I am trying to consume message from an endpoint defined in my route. The
>> queue to which the consumer is listening, has two different nature of
>> messages.
>>
>> For eg,
>>
>> I have a queue, say "queue:one" which has messages of type Foo and Bar.
>> When
>> the consumer starts listening and on message, I am getting an exception
>> with
>> message like "Unable to convert body from Foo to Bar"
>>
>> I am using camel-spring for all my configuration. My routing in context
>> file
>> is,
>>
>> <camel:route>
>>  <camel:from uri="queue:one" />
>>  <camel:transacted ref="required" />
>>  <camel:bean ref="foo" method="saveOne" />
>>  <camel:bean ref="bar" method="saveOne" />
>> </camel:route>
>>
>> Thanks in advance.
>>
>> - SK
>>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message