[英]Apache Camel - Unable to propagate JMS Header Properties between Request - Response
I am trying to save a value on the Camel Exchange between a Request - Response invocation against a QPID endpoint. 我试图在对QPID端点的请求-响应调用之间的Camel交换上保存一个值。
You can see from my code that I set a Header (and Property) before i invoke the Endpoint. 您可以从我的代码中看到,在调用端点之前,我已经设置了标题(和属性)。 Upon return the same Header and Property Values are null.
返回时,相同的Header和Property Values为null。
I basically want to keep a track of the fileName and filePath so that I can write the results into the same location 我基本上想跟踪fileName和filePath,以便可以将结果写入相同的位置
Really struggling with this. 真的为此苦苦挣扎。
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
}
}
includeAllJMSXProperties
is probably what you are looking for , includeAllJMSXProperties
可能是您正在寻找的东西,
Camel 2.11.2/2.12: Whether to include all JMSXxxx properties when mapping from JMS to Camel Message.
Camel 2.11.2 / 2.12:从JMS映射到Camel消息时是否包括所有JMSXxxx属性。 When set to true properties such as JMSXAppID, and JMSXUserID etc will be included.
当设置为true时,将包括JMSXAppID和JMSXUserID等属性。 Note: If you are using a custom headerFilterStrategy then this option does not apply.
注意:如果使用自定义headerFilterStrategy,则此选项不适用。
Source : https://camel.apache.org/jms.html 来源: https : //camel.apache.org/jms.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.