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