0

I'm basically new to camel. I set up a camel context with two routes that are using seda endpoints. Simplyfying, all starts with a "from" file endpoint (sorry for the terminology if wrong) listening on a directory:

<route>
    <from uri="file:mydir"/>
    <process ref="a bean that change the body of the message by setting a custom object"/>
    <to uri="seda:incoming"/>
</route>
<route>
    <from uri="seda:incoming"/>
    <process ref="a bean that does something with the custom object above"/>
    ....
</route>

now, what described above works perfectly but i need to change seda with activemq queues and after doing that the body of the message received by the 2nd processor is empty.

How can I obtain the same behaviour of seda endpoints using activemq channels?

Andrea
  • 2,714
  • 3
  • 27
  • 38
  • It could be useful to see what you do in 'a bean that change the body of the message by setting a custom object' – Frederic Close Sep 18 '13 at 20:43
  • Can you show the routes that is not working. – techuser soma Sep 18 '13 at 21:58
  • HI, thanks for responses. The first bean is doing simply something like (on the last line of the process method) exchange.getIn().setBody(myCustomBean) and exchange.getIn().setHeader("inputfile", aFileInstance). Both the body and the "inputfile" header are null on the second processor (when using activemq) – Andrea Sep 19 '13 at 02:58
  • I don't know if is the route that is not working. Goind with debugger I see that with seda all is done in memory and the message exchanged is a GenericFileMessage. When using activemq the message is instead a JMSMessage and only the original message (the one that comes from the "file:mydir") is exchanged between routes; is not the same instance, a new JMSMessage instance is created with different id (even I would expect the same because I'm running the embedded activemq) but anyway, the body and the header previously set are null. – Andrea Sep 19 '13 at 03:02
  • 1
    JMS has restrictions what can be sent. See about mapping message sections at: http://camel.apache.org/jms – Claus Ibsen Sep 19 '13 at 06:11
  • Thanks Claus, probably is my fault but I don't read any problem with my example...should be (behind the scenes) an ObjectMessage (with my custom object which is serializable) with an ObjectProperty in the header (the java.io.File instance). Am I wrong? – Andrea Sep 19 '13 at 06:36

1 Answers1

0

exchange.getIn().setBody(myCustomBean)

and

exchange.getIn().setHeader("inputfile", aFileInstance)

If you expect to get some result when aquiring from activemq queue, you should send serializable object to queue. Otherwise object will not be transferred. At your case there's no guarantee that myCustomBean and aFileInstance are serializable. Basically try sending the Strings into the queue. Or make your objects serializable.

Archer
  • 5,073
  • 8
  • 50
  • 96
  • My object implements serializable and java.io.File too – Andrea Sep 20 '13 at 19:27
  • Does your bean implements #writeObject, #readObject and #readObjectNoData? Details here: http://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html – Archer Sep 20 '13 at 19:33
  • Archer, we are going off-topic: Serializable is a "marker" and "special" interface: it means something more than other interfaces...read carefully what is written in the mentioned page. – Andrea Sep 21 '13 at 08:08