You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by James Green <ja...@gmail.com> on 2015/01/08 16:36:02 UTC

RecipientList to queue?

This errors:

        from(source())
                .transacted()
                .unmarshal(jacksonUnmarshall)
                .process(router)
                .recipientList(simple("${body.media}"))
                .marshal(jacksonMarshall);

The router sets the In of the Exchange to an object that has a List<String>
media. This is as single String of value "activemq:queue:foo".

The error:

15:29:32,463  WARN org.apache.camel.component.jms.JmsBinding:486
createJmsMessage() - Cannot determine specific JmsMessage type to use from
body class. Will use generic JmsMessage. Body class:
com.foo.server.ngw.msgtosend.MessageToSend. If you want to send a POJO then
your class might need to implement java.io.Serializable, or you can force a
specific type by setting the jmsMessageType option on the JMS endpoint.

I tried with marshal before the recipientList but then ${body.media} cannot
be found.

I'm guessing I'm bending things in ways not intended. The router wants to
set which media(s) the message should be transmitted onwards to. Camel
should then transmit to those as a set of queues.

Pretty simple, but crashes. Suggestions?

James

Re: RecipientList to queue?

Posted by Claus Ibsen <cl...@gmail.com>.
You can store the media as a header and then marshal the body, so your
recipient list can use a header instead of body for its destinations

On Fri, Jan 9, 2015 at 8:30 AM, James Green <ja...@gmail.com> wrote:
> I eventually solved this but making the media list return a set of
> "direct:<value>" strings. Then, a set of separate routes from
> direct:<value> to jms:queue:<value> via a Jackson marshaller however this
> isn't particularly dynamic.
>
> On 8 January 2015 at 17:43, Claus Ibsen <cl...@gmail.com> wrote:
>
>> The WARN is from camel-jms when you send to a jms endpoint and the
>> message body type cannot be determined to match a suitable JMS type.
>>
>> When this happens it fallback to use Object type which is serialized
>> java objects which often is not desired.
>>
>> See the jms page for more details and how mapping, and what you can do
>> http://camel.apache.org/jms
>>
>> On Thu, Jan 8, 2015 at 4:36 PM, James Green <ja...@gmail.com>
>> wrote:
>> > This errors:
>> >
>> >         from(source())
>> >                 .transacted()
>> >                 .unmarshal(jacksonUnmarshall)
>> >                 .process(router)
>> >                 .recipientList(simple("${body.media}"))
>> >                 .marshal(jacksonMarshall);
>> >
>> > The router sets the In of the Exchange to an object that has a
>> List<String>
>> > media. This is as single String of value "activemq:queue:foo".
>> >
>> > The error:
>> >
>> > 15:29:32,463  WARN org.apache.camel.component.jms.JmsBinding:486
>> > createJmsMessage() - Cannot determine specific JmsMessage type to use
>> from
>> > body class. Will use generic JmsMessage. Body class:
>> > com.foo.server.ngw.msgtosend.MessageToSend. If you want to send a POJO
>> then
>> > your class might need to implement java.io.Serializable, or you can
>> force a
>> > specific type by setting the jmsMessageType option on the JMS endpoint.
>> >
>> > I tried with marshal before the recipientList but then ${body.media}
>> cannot
>> > be found.
>> >
>> > I'm guessing I'm bending things in ways not intended. The router wants to
>> > set which media(s) the message should be transmitted onwards to. Camel
>> > should then transmit to those as a set of queues.
>> >
>> > Pretty simple, but crashes. Suggestions?
>> >
>> > James
>>
>>
>>
>> --
>> 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
>> hawtio: http://hawt.io/
>> fabric8: http://fabric8.io/
>>



-- 
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
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: RecipientList to queue?

Posted by James Green <ja...@gmail.com>.
I eventually solved this but making the media list return a set of
"direct:<value>" strings. Then, a set of separate routes from
direct:<value> to jms:queue:<value> via a Jackson marshaller however this
isn't particularly dynamic.

On 8 January 2015 at 17:43, Claus Ibsen <cl...@gmail.com> wrote:

> The WARN is from camel-jms when you send to a jms endpoint and the
> message body type cannot be determined to match a suitable JMS type.
>
> When this happens it fallback to use Object type which is serialized
> java objects which often is not desired.
>
> See the jms page for more details and how mapping, and what you can do
> http://camel.apache.org/jms
>
> On Thu, Jan 8, 2015 at 4:36 PM, James Green <ja...@gmail.com>
> wrote:
> > This errors:
> >
> >         from(source())
> >                 .transacted()
> >                 .unmarshal(jacksonUnmarshall)
> >                 .process(router)
> >                 .recipientList(simple("${body.media}"))
> >                 .marshal(jacksonMarshall);
> >
> > The router sets the In of the Exchange to an object that has a
> List<String>
> > media. This is as single String of value "activemq:queue:foo".
> >
> > The error:
> >
> > 15:29:32,463  WARN org.apache.camel.component.jms.JmsBinding:486
> > createJmsMessage() - Cannot determine specific JmsMessage type to use
> from
> > body class. Will use generic JmsMessage. Body class:
> > com.foo.server.ngw.msgtosend.MessageToSend. If you want to send a POJO
> then
> > your class might need to implement java.io.Serializable, or you can
> force a
> > specific type by setting the jmsMessageType option on the JMS endpoint.
> >
> > I tried with marshal before the recipientList but then ${body.media}
> cannot
> > be found.
> >
> > I'm guessing I'm bending things in ways not intended. The router wants to
> > set which media(s) the message should be transmitted onwards to. Camel
> > should then transmit to those as a set of queues.
> >
> > Pretty simple, but crashes. Suggestions?
> >
> > James
>
>
>
> --
> 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
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
>

Re: RecipientList to queue?

Posted by Claus Ibsen <cl...@gmail.com>.
The WARN is from camel-jms when you send to a jms endpoint and the
message body type cannot be determined to match a suitable JMS type.

When this happens it fallback to use Object type which is serialized
java objects which often is not desired.

See the jms page for more details and how mapping, and what you can do
http://camel.apache.org/jms

On Thu, Jan 8, 2015 at 4:36 PM, James Green <ja...@gmail.com> wrote:
> This errors:
>
>         from(source())
>                 .transacted()
>                 .unmarshal(jacksonUnmarshall)
>                 .process(router)
>                 .recipientList(simple("${body.media}"))
>                 .marshal(jacksonMarshall);
>
> The router sets the In of the Exchange to an object that has a List<String>
> media. This is as single String of value "activemq:queue:foo".
>
> The error:
>
> 15:29:32,463  WARN org.apache.camel.component.jms.JmsBinding:486
> createJmsMessage() - Cannot determine specific JmsMessage type to use from
> body class. Will use generic JmsMessage. Body class:
> com.foo.server.ngw.msgtosend.MessageToSend. If you want to send a POJO then
> your class might need to implement java.io.Serializable, or you can force a
> specific type by setting the jmsMessageType option on the JMS endpoint.
>
> I tried with marshal before the recipientList but then ${body.media} cannot
> be found.
>
> I'm guessing I'm bending things in ways not intended. The router wants to
> set which media(s) the message should be transmitted onwards to. Camel
> should then transmit to those as a set of queues.
>
> Pretty simple, but crashes. Suggestions?
>
> James



-- 
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
hawtio: http://hawt.io/
fabric8: http://fabric8.io/