Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

How to catch reply messages in InOut MEP?

$
0
0
To explain my problem I provide the route in a diagram of my context
component.
It is composed by 2 main routes for the different message directions.

My problem is now, that I have to inform the aggregator, when the
message has left the route via the MESSAGE_OUT endpoint.
When the message can not be delivered by the endpoint, I catch the
appropriate exception and send the according response message.
But if the message was delivered by the endpoint, the aggregator shall
send the ack response back via the internal send endpoint.

My idea was to define the route from aggregator to MESSAGE_OUT endpoint
in InOut MEP. But I did not understand this concept yet.

To set the InOut MEP i can just set in the route:
from(Endpoints.SEGMENT_IN.seda())
.routeId(Endpoints.SEGMENT_IN.uri(this.config.getPrefix()))
// check an conversion to internal bean format
.process(first_check)
.unmarshal(usedFormat)
.process(bean2msg)
.choice()
.when(header(HeaderKeys.TYPE.key()).isEqualTo(MSG.UserMessageType.RESP.toString()))
.process(send_controller) // process
response messages
.otherwise()
// aggregate messages
.aggregate(header(HeaderKeys.MID.key()),
aggregation).completionPredicate(aggregation)
// cannot be used unless Camel aggregator
implements discardOnFailure()
// .closeCorrelationKeyOnCompletion(CLOSED_CORRELATION_KEY_CACHE_SIZE)
// set InOut MEP
.setExchangePattern(ExchangePattern.InOut)
.completionTimeout(TimeUnit.SECONDS.toMillis(config.getT_seg())).discardOnCompletionTimeout()
.to(Endpoints.MESSAGE_OUT.direct());

But how can I catch the reply message in the aggregator? Do I have to
implement a special method for reply messages? Or are the reply messages
received also by the aggregate method?

How can I decide between normal and reply messages?

Or is there any other solution for this problem instead of InOut MEP?

Thanks, Sven

Viewing all articles
Browse latest Browse all 5648

Trending Articles