【问题标题】:How to set headers from bean integration method call in a camel route如何在骆驼路线中从 bean 集成方法调用中设置标头
【发布时间】:2016-05-06 08:37:12
【问题描述】:

根据 bean 集成的方法调用设置标头需要帮助。 在我的应用程序中,我正在使用自定义 POJO,并且在我实际通过线路发送消息之前,我想要在交换器上设置标头,但不想在我的 bean 中这样做,而是在我的春天做DSL 是为路由编写的。 我知道通常从方法返回的值作为消息的正文发送到下一个端点,但我想发送作为标头返回的值。 我附上了我的路线需要和想要的示例:

<route id="someRoute">
<from ref="InboundAsyncEndpoint" />
<to  uri="bean:validatorBean?method=validateMessageInternals(MyCostomMessagePojo obj)" />
<choice>
    <when>
        <simple>
            ${body.getMetaData().getFinalDestinationName()} == 'AMQEndpoint'
        </simple>
        <to uri="bean:payloadAndHeaderExtractor?extractHeader(MyCostomMessagePojo obj)" /> 
        <to uri="bean:payloadAndHeaderExtractor?extractPayload(MyCostomMessagePojo obj)" /> <!-- i want the headers being set on the exchange from the map that is returnd from the previous bean and method -->
        <to uri="activemq:someQueue"
    </when>
    <otherwise>
        ...
        ...
    </otherwise>
</choice>

【问题讨论】:

    标签: java spring apache-camel


    【解决方案1】:

    您可以通过以下方式做到这一点:

    <setHeader headerName="YOUR_HEADER">
         <simple>bean:payloadAndHeaderExtractor?extractHeader(MyCostomMessagePojo obj)</simple>
    </setHeader>
    

    希望这会有所帮助。

    R.

    【讨论】:

      猜你喜欢
      • 2015-09-27
      • 2013-12-22
      • 1970-01-01
      • 1970-01-01
      • 2018-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多