You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by redpower1989 <re...@hotmail.com> on 2016/07/18 08:59:15 UTC
Convert message into two converters and dilliver them to one
destination
Hello,
At the momemt my camel route is doing this thing:
1) incoming message.
2) unmarshal it
3) if type of A use converterA
else type of B use converterB
4) marshal it
5) to destination.
I was wondering if and how can i do.
1)incoming message
2) unmarshal it
3) if type of A converterA
and converterC
4) marshal the two converted messages
5) to destination.
Thanks.
--
View this message in context: http://camel.465427.n5.nabble.com/Convert-message-into-two-converters-and-dilliver-them-to-one-destination-tp5785205.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Convert message into two converters and dilliver them to one
destination
Posted by redpower1989 <re...@hotmail.com>.
i use the JmsMessageID to filter the message and detect if they are
duplicate. I think i get where i do my mistake. Your suggestion to move
idempotentConsumer in the "source" is what i want.
--
View this message in context: http://camel.465427.n5.nabble.com/Convert-message-into-two-converters-and-dilliver-them-to-one-destination-tp5785205p5785420.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Convert message into two converters and dilliver them to one destination
Posted by Quinn Stevenson <qu...@pronoia-solutions.com>.
What are you using for you expression that generates the messageId? I don’t see anything in the routes below (in fact, the last route isn’t valid).
Can you explain what sort of duplicate you are trying to avoid? It would seem that given the same input, the result of converting to object A or B would be the same. Therefore, using the idempotentConsumer in the “source” route would accomplish what you’re after.
> On Jul 21, 2016, at 4:50 AM, redpower1989 <re...@hotmail.com> wrote:
>
> Let me make it more clear because i am not only send the message to the
> queue.
>
> <route>
> <from uri=“{{source}}” />
> <multicast>
> <to uri=“direct:a” />
> <to uri=“direct:b” />
> </multicast>
> </route>
>
> <route>
> <from uri=“direct:a” />
> <convertBodyTo type=“objectTypeA” />
> <to uri="direct:c" />
> </route>
>
> <route>
> <from uri=“direct:b” />
> <convertBodyTo type=“objectTypeB” />
> <to uri="direct:c" />
> </route>
>
> <route>
> <from uri="direct:c">
> <marshal>
> <idempotentConsumer messageIdRepositoryRef="myRepo" skipDuplicate="false">
> </idempotentConsumer>
> <to uri=“activemq:FOO.BAR” />
> </route>
>
> So basically my two sub-routes use somehow the same idempotent repository. I
> want basically the incoming message to copy it send it to two different
> converters and the new two converted messages to marshal it and send it to
> the queue. But my problem at the moment is the idempotent repo because when
> you use multicast the copied message has the same massageId.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Convert-message-into-two-converters-and-dilliver-them-to-one-destination-tp5785205p5785329.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Convert message into two converters and dilliver them to one
destination
Posted by redpower1989 <re...@hotmail.com>.
Let me make it more clear because i am not only send the message to the
queue.
<route>
<from uri=“{{source}}” />
<multicast>
<to uri=“direct:a” />
<to uri=“direct:b” />
</multicast>
</route>
<route>
<from uri=“direct:a” />
<convertBodyTo type=“objectTypeA” />
<to uri="direct:c" />
</route>
<route>
<from uri=“direct:b” />
<convertBodyTo type=“objectTypeB” />
<to uri="direct:c" />
</route>
<route>
<from uri="direct:c">
<marshal>
<idempotentConsumer messageIdRepositoryRef="myRepo" skipDuplicate="false">
</idempotentConsumer>
<to uri=“activemq:FOO.BAR” />
</route>
So basically my two sub-routes use somehow the same idempotent repository. I
want basically the incoming message to copy it send it to two different
converters and the new two converted messages to marshal it and send it to
the queue. But my problem at the moment is the idempotent repo because when
you use multicast the copied message has the same massageId.
--
View this message in context: http://camel.465427.n5.nabble.com/Convert-message-into-two-converters-and-dilliver-them-to-one-destination-tp5785205p5785329.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Convert message into two converters and dilliver them to one destination
Posted by Quinn Stevenson <qu...@pronoia-solutions.com>.
I’m not following your logic in this route - both of the sub-routes are using the same idempotent repository, so I think you’ll wind up marking items as duplicates when they really are not.
Did you mean to put the idempotent consumer on the from=source route?.
> On Jul 20, 2016, at 3:42 AM, redpower1989 <re...@hotmail.com> wrote:
>
> Thanks for answer. Does anyone know if you can change the messageId when you
> are using multicast? At the moment multicast copy the message and the new
> two messages have the same message ID. If i have a idempotentConsumer before
> a producer endpoint it will block my second message even if it has been
> converted to something different. For example:
>
>
> <route>
> <from uri=“{{source}}” />
> <multicast>
> <to uri=“direct:a” />
> <to uri=“direct:b” />
> </multicast>
> </route>
>
> <route>
> <from uri=“direct:a” />
> <convertBodyTo type=“objectTypeA” />
> <idempotentConsumer messageIdRepositoryRef="myRepo" skipDuplicate="false">
> </idempotentConsumer>
> <to uri=“activemq:FOO.BAR” />
> </route>
>
> <route>
> <from uri=“direct:b” />
> <convertBodyTo type=“objectTypeB” />
> <idempotentConsumer messageIdRepositoryRef="myRepo" skipDuplicate="false">
> </idempotentConsumer>
> <to uri=“activemq:FOO.BAR” />
> </route>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Convert-message-into-two-converters-and-dilliver-them-to-one-destination-tp5785205p5785266.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Convert message into two converters and dilliver them to one
destination
Posted by redpower1989 <re...@hotmail.com>.
Thanks for answer. Does anyone know if you can change the messageId when you
are using multicast? At the moment multicast copy the message and the new
two messages have the same message ID. If i have a idempotentConsumer before
a producer endpoint it will block my second message even if it has been
converted to something different. For example:
<route>
<from uri=“{{source}}” />
<multicast>
<to uri=“direct:a” />
<to uri=“direct:b” />
</multicast>
</route>
<route>
<from uri=“direct:a” />
<convertBodyTo type=“objectTypeA” />
<idempotentConsumer messageIdRepositoryRef="myRepo" skipDuplicate="false">
</idempotentConsumer>
<to uri=“activemq:FOO.BAR” />
</route>
<route>
<from uri=“direct:b” />
<convertBodyTo type=“objectTypeB” />
<idempotentConsumer messageIdRepositoryRef="myRepo" skipDuplicate="false">
</idempotentConsumer>
<to uri=“activemq:FOO.BAR” />
</route>
--
View this message in context: http://camel.465427.n5.nabble.com/Convert-message-into-two-converters-and-dilliver-them-to-one-destination-tp5785205p5785266.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Convert message into two converters and dilliver them to one destination
Posted by Quinn Stevenson <qu...@pronoia-solutions.com>.
I don’t think multicast will do what you’re after - it sends the same message to multiple endpoints.
I think you could accomplish what you’re after using three routes:
<route>
<from uri=“{{source}}” />
<multicast>
<to uri=“direct:a” />
<to uri=“direct:b” />
</multicast>
</route>
<route>
<from uri=“direct:a” />
<convertBodyTo type=“objectTypeA” />
<to uri=“activemq:FOO.BAR” />
</route>
<route>
<from uri=“direct:b” />
<convertBodyTo type=“objectTypeB” />
<to uri=“activemq:FOO.BAR” />
</route>
> On Jul 19, 2016, at 7:21 AM, redpower1989 <re...@hotmail.com> wrote:
>
> Maybe i could make it more clear. Can i use multicast with too converters ?
> Something like that
>
> <multicast>
> <convertBodyTo type="objectTypeA" />
> <convertBodyTo type="objectTypeB" />
> </multicast>
>
> <to uri="activemq:FOO.BAR"/>
>
> I am trying that but i get the message to be converted only to typeB. Is
> there any possible way to copy the message convert it to A and B and send it
> to queue?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Convert-message-into-two-converters-and-dilliver-them-to-one-destination-tp5785205p5785254.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Convert message into two converters and dilliver them to one
destination
Posted by redpower1989 <re...@hotmail.com>.
Maybe i could make it more clear. Can i use multicast with too converters ?
Something like that
<multicast>
<convertBodyTo type="objectTypeA" />
<convertBodyTo type="objectTypeB" />
</multicast>
<to uri="activemq:FOO.BAR"/>
I am trying that but i get the message to be converted only to typeB. Is
there any possible way to copy the message convert it to A and B and send it
to queue?
--
View this message in context: http://camel.465427.n5.nabble.com/Convert-message-into-two-converters-and-dilliver-them-to-one-destination-tp5785205p5785254.html
Sent from the Camel - Users mailing list archive at Nabble.com.