You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by nigel <ni...@pimco.com> on 2013/10/03 16:58:20 UTC

SJMS component doesnt convert GenricFile to a string but JMS does

Guys
With a route as below
   from("file:fname.txt").to("sjms:queue:qname")
we get an error because the Jms message type is of type Message.
The issue seems to be in JmsMessageHelper.discoverMessageTypeFromPayload.
GenericFile is the payload object which is not serializable itself. sjms has
this line:
else if (Serializable.class.isInstance(payload)) {
                answer = JmsMessageType.Object;
JMS component has this code in the JmsBinding class
case Object:
            ObjectMessage message = session.createObjectMessage();
            if (body != null) {
                try {
                    Serializable payload =
context.getTypeConverter().mandatoryConvertTo(Serializable.class, exchange,
body);
                    message.setObject(payload);

I assume that the converter for GenericFile does some extra magic. 
Is there a workaround or am I missing a trick?
Thanks
Nigel




--
View this message in context: http://camel.465427.n5.nabble.com/SJMS-component-doesnt-convert-GenricFile-to-a-string-but-JMS-does-tp5740823.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: SJMS component doesnt convert GenricFile to a string but JMS does

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah we should have that out of the box, like camel-jms.
You are welcome to log a JIRA ticket

You can convert the body before sending to JMS.

.convertBodyTo(String.class)

to use javax.jms.TextMessage

or

.convertBodyTo(FileInputStream.class)

to be byte based.



On Thu, Oct 3, 2013 at 4:58 PM, nigel <ni...@pimco.com> wrote:
> Guys
> With a route as below
>    from("file:fname.txt").to("sjms:queue:qname")
> we get an error because the Jms message type is of type Message.
> The issue seems to be in JmsMessageHelper.discoverMessageTypeFromPayload.
> GenericFile is the payload object which is not serializable itself. sjms has
> this line:
> else if (Serializable.class.isInstance(payload)) {
>                 answer = JmsMessageType.Object;
> JMS component has this code in the JmsBinding class
> case Object:
>             ObjectMessage message = session.createObjectMessage();
>             if (body != null) {
>                 try {
>                     Serializable payload =
> context.getTypeConverter().mandatoryConvertTo(Serializable.class, exchange,
> body);
>                     message.setObject(payload);
>
> I assume that the converter for GenericFile does some extra magic.
> Is there a workaround or am I missing a trick?
> Thanks
> Nigel
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/SJMS-component-doesnt-convert-GenricFile-to-a-string-but-JMS-does-tp5740823.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen