我有这条路
from(URI_WEBSERVICE)
.convertBodyTo(Entrada.class)
.process(new ProcessorTratarWS())
.pollEnrich("ftp://10.100.8.2/entradaCamel?username=USER&password=PASSWORD&delete=true&fileName=${property.archivoRespuesta}", timeOut, new EstrategiaConfirmacion())
.to(WS_RESPONDER)在ProcessorTratarWS()中,我设置了property.archivoRespuesta的值,是pollEnrich应该不加载的文件的名称。
但是,文档显示"PollEnrich没有访问Exchange的权限“。这意味着PollEnrich无法读取${property.archivoRespuesta}的值。
在骆驼身上有什么替代的方法吗,就像我在尝试的一样?
谢谢!
发布于 2015-07-02 13:16:00
来自http://camel.apache.org/content-enricher.html
..。您可以使用收件人列表和动态端点,并在收件人列表上定义一个AggregationStrategy,而不是使用充实。..。
试一试如下:
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)编辑:
以上代码用于在FTP服务器中保存文件。如果要从FTP服务器轮询文件,可以尝试
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); 免责声明:我没有经常使用轮询消费者,可能会有更优雅、更高效的解决方案
发布于 2022-01-13 09:03:46
您可以使用“简单”表达式,也可以使用"exchangeProperty“代替字符串中的”属性“。
from(URI_WEBSERVICE)
.convertBodyTo(Entrada.class)
.process(new ProcessorTratarWS())
.pollEnrich().simple("ftp://10.100.8.2/entradaCamel?username=USER&password=PASSWORD&delete=true&fileName=${exchangeProperty.archivoRespuesta}")
.timeout(timeOut)
.aggregationStrategy(new EstrategiaConfirmacion())
.to(WS_RESPONDER)https://stackoverflow.com/questions/31145045
复制相似问题