You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Sven Bauhan <sv...@ast.dfs.de> on 2013/03/01 14:29:01 UTC
Reply messages from aggregator
Hi,
I'm quite new to Camel and I have a problem to understand the basic
principle of sending replys back to a sender.
I try to implement a protocol that aggregates segments to a complete
message. For each segment a reply message is expected by the sender.
My route is now:
JaxbDataFormat jaxb = new JaxbDataFormat();
ATSMAggregationStrategy aggregation = new
ATSMAggregationStrategy();
from("direct:atsm-segment")
.unmarshal(jaxb).aggregate(xpath("/MSG/MID"), aggregation)
.completionPredicate(aggregation).to("direct:atsm-out");
Do I have to set the exchange pattern of the aggregator to InOut? How
can I do this?
How is the reply message defined? Do I have to set the out message in
the aggregation strategy?
How do I trigger sending of a reply message?
How is the reply messages routed back to the sender?
Is the reply messages processed automatically (JAXB)?
Thanks,
Sven Bauhan
Re: Reply messages from aggregator
Posted by Henryk Konsek <he...@gmail.com>.
Hi Sven,
> I have to implement a protocol called ATS-M.
I'm afraid that we still don't get the protocol you want to implement.
Could you elaborate this topic a little bit?
> By the way, I did not understand yet, what seda means and what is the
> difference to direct.
Seda [1] is in-memory message queue. It's a little bit like the
"asynchronous direct" component :) .
Best regards.
[1] http://camel.apache.org/seda.html
--
Henryk Konsek
http://henryk-konsek.blogspot.com
Re: Reply messages from aggregator
Posted by Sven Bauhan <sv...@ast.dfs.de>.
On 03/10/13 02:53, Christian Müller wrote:
> Can you explain in more detail what you want to do? I didn't understand
> your requirement...
I have to implement a protocol called ATS-M. It splits messages into
segments for transmission. At the receiver the segments are aggregated
to the original message.
> One question: Your "aggregation" object implements Predicate *AND*
> AggregationStrategy?
Sure, the predicate belongs to the aggregation. So I put them in the
same class as they belong together.
> By looking a your example, your direct endpoint receives (String/Byte
> array/...) messages and convert it into a JAXB annotated Java Object. You
> aggregate all messages based on the "MSG/MID" element until your
> aggregation predicate indicates the end. Afterwards you send the aggregated
> messages to another direct endpoint.
correct
> *IF* you want to send back a message at the time it receives in the
> aggregator, I would do something like this
The problem is, that I cannot just send a reply if a message is
received. The aggregator has to parse the message and then it replies an
ACK or a fault message. This can only be done in the aggregator, cause
the new segment has to be checked against the incomplete message in the
aggregator.
So what I need is a second output port from the aggregator where the
reply messages are sent and which can be taken into a camel route.
> from("direct:atsm-segment")
> .unmarshal(jaxb)
> .inOnly("seda:aggregator")
> .inOut("bean:myResponseBuilder")
> .marshal(jaxb);
>
> from("seda:aggregator")
> .aggregate(xpath("/MSG/MID"),
> aggregation).completionPredicate(aggregation)
> .to("direct:atsm-out");
By the way, I did not understand yet, what seda means and what is the
difference to direct.
A jaxb marshaling is not needed. I want to process the data internally.
I added a processor to the route to put the header information in the
XML structure into the camel message header:
from("direct:atsm-segment")
.unmarshal(jaxb)
.process(atsm_process)
.aggregate(header("MID"),
aggregation).completionPredicate(aggregation)
// .reply_to("")
.to("direct:atsm-out");
Thanks, Sven
Re: Reply messages from aggregator
Posted by Christian Müller <ch...@gmail.com>.
Can you explain in more detail what you want to do? I didn't understand
your requirement...
One question: Your "aggregation" object implements Predicate *AND*
AggregationStrategy?
By looking a your example, your direct endpoint receives (String/Byte
array/...) messages and convert it into a JAXB annotated Java Object. You
aggregate all messages based on the "MSG/MID" element until your
aggregation predicate indicates the end. Afterwards you send the aggregated
messages to another direct endpoint.
*IF* you want to send back a message at the time it receives in the
aggregator, I would do something like this
from("direct:atsm-segment")
.unmarshal(jaxb)
.inOnly("seda:aggregator")
.inOut("bean:myResponseBuilder")
.marshal(jaxb);
from("seda:aggregator")
.aggregate(xpath("/MSG/MID"),
aggregation).completionPredicate(aggregation)
.to("direct:atsm-out");
Best,
Christian
On Fri, Mar 1, 2013 at 2:29 PM, Sven Bauhan <sv...@ast.dfs.de> wrote:
> Hi,
>
> I'm quite new to Camel and I have a problem to understand the basic
> principle of sending replys back to a sender.
> I try to implement a protocol that aggregates segments to a complete
> message. For each segment a reply message is expected by the sender.
> My route is now:
>
> JaxbDataFormat jaxb = new JaxbDataFormat();
> ATSMAggregationStrategy aggregation = new
> ATSMAggregationStrategy();
> from("direct:atsm-segment")
> .unmarshal(jaxb).aggregate(**xpath("/MSG/MID"), aggregation)
> .completionPredicate(**aggregation).to("direct:atsm-**out");
>
> Do I have to set the exchange pattern of the aggregator to InOut? How can
> I do this?
> How is the reply message defined? Do I have to set the out message in the
> aggregation strategy?
> How do I trigger sending of a reply message?
> How is the reply messages routed back to the sender?
> Is the reply messages processed automatically (JAXB)?
>
> Thanks,
> Sven Bauhan
>
>
--