我正在尝试在针对QPID端点的请求 - 响应调用之间保存Camel Exchange上的值。
你可以从我的代码中看到我在调用端点之前设置了一个Header(和Property)。返回时,相同的标题和属性值为空。
我基本上想要跟踪fileName和filePath,以便我可以将结果写入同一位置
真的很挣扎。
import org.apache.camel.builder.RouteBuilder;
import org.springframework.beans.factory.annotation.Value;
public class ProcessingRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
//@formatter:off
from("file:/home/molko/in/?recursive=true&include=.*.txt")
.log("File read from disk : ${file:name}")
.doTry()
.setHeader("JMSReplyTo", constant("response-1"; {create:always, node:{type:queue}}"))
.setHeader("JMSCorrelationID", constant(java.util.UUID.randomUUID().toString()))
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
final String fileParent = exchange.getIn().getHeader("CamelFileParent", String.class);
final String endPath = fileParent.substring(fileParent.lastIndexOf('/') + 1);
exchange.getIn().setHeader("endPath", endPath);
exchange.setProperty("endPath", endPath);
}
})
.to(amqp:request-1;{node:{type:queue}}?preserveMessageQos=true?exchangePattern=InOut")
.doCatch(Exception.class)
.log("Failed : ${file:name}")
.log("${exception.stacktrace}")
.stop();
from("amqp:response-1; {create:always, node:{type:queue}}")
.log("Received from qpid broker : ${date:now}")
.doTry()
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
byte[] response = exchange.getIn().getBody(byte[].class);
System.out.println("properties : " + exchange.getProperties());
System.out.println("headers : " + exchange.getIn().getHeaders());
}
})
.to("file:/home/molko/out")
.doCatch(Exception.class)
.log("Failed from qpid brokre : ${date:now}")
.log("${exception.stacktrace}")
.stop();
//@formatter:on
}
}
答案 0 :(得分:0)
includeAllJMSXProperties
可能就是你要找的东西,
Camel 2.11.2 / 2.12:是否包含所有JMSXxxx属性 从JMS映射到Camel消息。设置为true属性时如 将包括JMSXAppID和JMSXUserID等。注意:如果您正在使用 自定义headerFilterStrategy然后此选项不适用。