On Mon, Jul 6, 2009 at 11:53 PM, <brian.xi...@thomsonreuters.com> wrote: > Hi, > > I am new to camel. I am having problem figuring out what is in the > message body in the following route. I was expecting a File object in > the body according to what camel documents say: > "By default the file endpoint sends a FileMessage which contains a File > as body. If you send this directly to the jms component the jms message > will only contain the File object but not the content." > > What it prints out is: Body class: [B > > public class MyRouteBuilder extends RouteBuilder { > > public void configure() { > > from("file:src/data?noop=true").to("jms:test.MyQueue"); > > from("jms:test.MyQueue").process(new Processor() { > > public void process(Exchange exchange) { > > Object body = exchange.getIn().getBody(); > > System.out.println("Body class: " + > body.getClass().getName()); > > } > > }); > > } > > Any idea? Yes you send the java.io.File over JMS and that cannot be done by nature. When you send it over JMS it will be converted to a javax.jms.BytesMessage, eg Camel will load the file content and send it as bytes to the JMS queue.
That is why it prints B[ etc. as its a byte array. You can use body.getClass().getCanonicalName() to display the class name that is more readable. And btw you can use the tracer to trace the messages instead of doing your own system out logger http://camel.apache.org/tracer.html > > What I am trying to do is, I have a file poller to poll a folder which > contains MS Word document. The poller sends the message the queue. The > comsumer of the queue will process the Word document etc. What is the > best way to do this? You got it most done you have the file content as a bytes. Then you can eg process it. What kind of framework do you want to use to process a MS Word file? You might wanna check up which kind of object types it expect the MS world file to work with. > > Thanks for your help! > > Brian > > > > > > -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus