My camel route is as follows (sample)
from (activemq:xyz) --- Receive the message from a QUEUE
to(smpp:abc) --- Submit the message to SMSC
to(cxf:hij) --- Based on SMSC response as success call the webservice
The problem I am facing is as below
I have few exchange properties/headers received from the queue, but after receiving the response from SMPP, my exchange headers/properties that I have sent are cleared and not available for me to call the webservice. What can I do to keep these values to be as it is untill I reach the end of route. I have no control on the SMSC implementation and cannot change the SMSC response. I am using SPRING dsl
You can consider using the enterprise integration pattern named Content Enricher for the SMPP part, with a custom AggregationStrategy
that 'keeps' your original exchange (with all the headers and properties), and takes what you need (the body, I presume?) from whatever SMSC does.
from (activemq:xyz)
.enrich(smpp:abc, new PreserveHeadersAndPropertiesAggregationStrategy())
.to(cxf:hij)
;
with
public class PreserveHeadersAndPropertiesAggregationStrategy implements AggregationStrategy {
@Override
public Exchange aggregate(Exchange original, Exchange resource) {
// use body from getIn() or getOut() depending on the exchange pattern...
original.getIn().setBody(resource.getIn().getBody());
original.getOut().setBody(resource.getOut().getBody());
return original;
}
}