I've quickly skimmed over the relevant source in camel-jms. It looks like
Camel reads the message body lazily, only when required. So
ObjectMessage.getObject() will only be called when the body is actually
required. In AMQ, this is the method that performs the deserialization and
would hypothetically fail with a ClassNotFoundException. So you want to
avoid calling this method by all means ;-)

Bad news is that, even if you don't explicitly read the body in your route,
Camel does manipulate the Exchange under the surface in a way that the
original body may be read at some point. Particularly when dispatching to
your ending JMS producer, where the original body should be sent.

However, there are good news if (a) your consumers can afford processing
BytesMessages instead of ObjectMessages, and (b) you don't mind coupling
your solution to AMQ (which you shouldn't mind doing – as your use case is
quite extraordinary). In that case, create a custom JmsBinding that
overrides the extractBodyFromJms method, and replaces the logic to read the
body from an ObjectMessage.

Instead of deserializing the object, you want to fetch the underlying
byte[]. To do this, cast the message to ActiveMQObjectMessage and call
storeContent() to slurp in the underlying byte[] into memory. Then call
getContent() which returns an AMQ ByteSequence. From this object you can
get access to the underlying byte[].

Quite a hack, but I would give it a shot if I were you ;-)

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Tue, Jul 30, 2013 at 3:44 PM, jduncan <jdun...@iqnavigator.com> wrote:

> Actually that also does not work for object messages.  Camel will still try
> to deserialize the object in the body.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-route-only-dealing-with-headers-tp5736452p5736502.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply via email to