camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Camillo <alancami...@gmail.com>
Subject Re: TypeConversionException RabbitMQ
Date Tue, 09 Dec 2014 22:18:11 GMT
Just to close this...

I should have used a marshal/unmarshal before and after send and receive a
message from RabbitMQ. It's lot of safer!

Thanks any way! ;)

On Tue, Dec 9, 2014 at 3:19 PM, Alan Camillo <alancamillo@gmail.com> wrote:

> Someone knows if this behavior is it normal?
>
> Thanks again!
> Alan Camillo
>
> On Tue, Dec 9, 2014 at 12:31 PM, Alan Camillo <alancamillo@gmail.com>
> wrote:
>
>> Sure! Here it is:
>>
>> ...
>>     @Override
>>     public void *process*(Exchange exchange) throws Exception {
>>
>>         A a = exchange.getIn()
>>                 .getHeader("BODY", *A.class*);
>>
>>         exchange.getIn().*setBody*(
>>                 a.getBs().get(
>>                         exchange.getProperty("CamelLoopIndex",
>> Integer.class))
>>                 , *B.class*);
>>     }
>> ...
>> Thanks!
>> Alan Camillo
>>
>> On Tue, Dec 9, 2014 at 3:45 AM, Willem Jiang <willem.jiang@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> Can you show us the code of IterateEmailsProcessor?
>>>
>>> --
>>> Willem Jiang
>>>
>>> Red Hat, Inc.
>>> Web: http://www.redhat.com
>>> Blog: http://willemjiang.blogspot.com (English)
>>> http://jnn.iteye.com (Chinese)
>>> Twitter: willemjiang
>>> Weibo: 姜宁willem
>>>
>>>
>>>
>>> On December 9, 2014 at 12:51:03 PM, Alan Camillo (alancamillo@gmail.com)
>>> wrote:
>>> > Look like a simple problem, but I can't see the solution.
>>> >
>>> > I have a class like the follow:
>>> > public class A {
>>> > public List Bs;
>>> > // getters and setters
>>> > }
>>> >
>>> > Than I receive this class from a RabbitMQ:
>>> >
>>> > from("rabbitmq://{{rabbitmq.host}}:{{rabbitmq.port}}/*sendmsg*
>>> > ").routeId("sendmsg")
>>> > .convertBodyTo(A.class)
>>> > .setHeader("BODY", new SimpleExpression("${body}"))
>>> > .setHeader("SIZE", new SimpleExpression("${body.bs.size}"))
>>> > .loop(new SimpleExpression("${header.SIZE}") )
>>> > .log("contador: ${header.CamelLoopIndex}")
>>> > .process(new IterateEmailsProcessor()) //<<<<<<<<<
Here I
>>> > put a *B.class* in the body to send to another process and I get the
>>> error
>>> > .inOnly("rabbitmq://{{rabbitmq.host}}:{{rabbitmq.port}}/
>>> > *othermsg*") //<<<<<<<<<< Exception came from
here
>>> > .end() ;
>>> >
>>> > Caused by: [org.apache.camel.TypeConversionException - Error during
>>> type
>>> > conversion from type: byte[] to the required type: *A* with value
>>> > [B@2aa6b2f7 due Cannot cast *B* to *A*]
>>> >
>>> > Can't I exchange different types through rabbitmq component?
>>> > Thank you!
>>> > Alan Camillo
>>> >
>>>
>>>
>>
>

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