Camel: pollEnrich and access to the Exchange
From http://camel.apache.org/content-enricher.html
... Instead of using enrich you can use Recipient List and have dynamic endpoints and define an AggregationStrategy on the Recipient List which then would work as a enrich would do. ...
try something like:
from(URI_WEBSERVICE)
.convertBodyTo(Entrada.class)
.process(new ProcessorTratarWS())
.recipientList(simple("ftp://10.100.8.2/entradaCamel?username=USER&password=PASSWORD&delete=true&fileName=${property.archivoRespuesta}")).aggregationStrategy(new EstrategiaConfirmacion())
.to(WS_RESPONDER)
Edit:
The above code is to save file in FTP server. If you want to poll file from the FTP server you can try
from(URI_WEBSERVICE)
.convertBodyTo(Entrada.class)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
// logic of ProcessorTratarWS goes here
ConsumerTemplate consumer=exchange.getContext().createConsumerTemplate();
String filename=exchange.getProperty("archivoRespuesta",String.class);
Object file=consumer.receiveBody("ftp://10.100.8.2/entradaCamel?username=USER&password=PASSWORD&delete=true&fileName="+filename,timeOut);
// logic of EstrategiaConfirmacion goes here
}
})
.to(WS_RESPONDER);
Disclaimer: I have not used polling consumer much and there could be more elegant/efficient solution