【问题标题】:How to access header and property from callee in ASynch Route in Apache Camel如何从 Apache Camel 的异步路由中调用的标头和属性
【发布时间】:2016-12-29 16:58:11
【问题描述】:

我有监听 ActiveMQ 队列的 Apache Camel Route。在处理过程中,路由会在某一时刻设置交换器上的标头和属性。

现在在集成测试期间,我们要检查标头和属性的值。

问题是,我们如何访问这两个东西,即。标题和属性。

我尝试使用 producerTemplate 的 asyncRequestBody/asyncRequestBodyAndHeader 等。使用 Future 对象我可以访问 Exchange,但是,我无法访问在 Exchange 上设置的标头和属性。

我已经确定路由是 InOut 类型的。

【问题讨论】:

  • 能否添加路由代码,包括headers/properties在哪里设置然后读取?

标签: apache-camel


【解决方案1】:

如果你能拿到exchange,你能不能不直接用exchange.getProperty(name)来得到你要找的property?

我在路线中设置了属性:

<setProperty propertyName="sampleProperty"> <simple>${body}</simple> </setProperty>

稍后使用 {property.sampleProperty} 检索它们

【讨论】:

  • 在我的情况下,路由是异步的,即它从队列中读取。我在想这就是为什么当我执行 exchange.getProperty(name) 时,它返回 null
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多