exchange message header to JMS properties

Camel will place the headers as camel exchange headers that will be converted automatically to JMS properties.

 

http://camel.apache.org/jms.html

Message format when sending

The exchange that is sent over the JMS wire must conform to the JMS Message spec.

For the exchange.in.header the following rules apply for the header keys:

  • Keys starting with JMS or JMSX are reserved.
  • exchange.in.headers keys must be literals and all be valid Java identifiers (do not use dots in the key name).
  • Camel replaces dots & hyphens and the reverse when when consuming JMS messages:
    . is replaced by _DOT_ and the reverse replacement when Camel consumes the message.
    - is replaced by _HYPHEN_ and the reverse replacement when Camel consumes the message.
  • See also the option jmsKeyFormatStrategy, which allows use of your own custom strategy for formatting keys.

For the exchange.in.header, the following rules apply for the header values:

  • The values must be primitives or their counter objects (such as Integer, Long, Character). The types, String, CharSequence, Date, BigDecimal and BigInteger are all converted to their toString() representation. All other types are dropped.

Camel will log with category org.apache.camel.component.jms.JmsBinding at DEBUG level if it drops a given header value. For example:

2008-07-09 06:43:04,046 [main           ] DEBUG JmsBinding
  - Ignoring non primitive header: order of class: org.apache.camel.component.jms.issues.DummyOrder with value: DummyOrder{orderId=333, itemId=4444, quantity=2}

Message format when receiving

Camel adds the following properties to the Exchange when it receives a message:

PropertyTypeDescription
org.apache.camel.jms.replyDestinationjavax.jms.DestinationThe reply destination.

Camel adds the following JMS properties to the In message headers when it receives a JMS message:

HeaderTypeDescription
JMSCorrelationIDStringThe JMS correlation ID.
JMSDeliveryModeintThe JMS delivery mode.
JMSDestinationjavax.jms.DestinationThe JMS destination.
JMSExpirationlongThe JMS expiration.
JMSMessageIDStringThe JMS unique message ID.
JMSPriorityintThe JMS priority (with 0 as the lowest priority and 9 as the highest).
JMSRedeliveredbooleanIs the JMS message redelivered.
JMSReplyTojavax.jms.DestinationThe JMS reply-to destination.
JMSTimestamplongThe JMS timestamp.
JMSTypeStringThe JMS type.
JMSXGroupIDStringThe JMS group ID.

As all the above information is standard JMS you can check the JMS documentation for further details.

 

http://camel.apache.org/how-to-remove-the-http-protocol-headers-in-the-camel-message.html

In camel there are a number of components that use the http protocol headers to do their business.
The components include camel-http, camel-jetty, camel-restlet, camel-cxf, etc.
If you are using these component, you may pay attention to the Http protocol headers:

  Exchange.CONTENT_ENCODING
  Exchange.CONTENT_TYPE
  Exchange.HTTP_BASE_URI
  Exchange.HTTP_CHARACTER_ENCODING
  Exchange.HTTP_METHOD
  Exchange.HTTP_PATH
  Exchange.HTTP_QUERY
  Exchange.HTTP_RESPONSE_CODE

If you don't want these headers to bother your other endpoints, you can remove these headers as follows:

  from("jetty://http://myhost:9000/myservice/")
    // Remove the header which name is start with CamelHttp, this DSL is new to Camel 2.3.0
    // You can use removeHeader if your camel version is lower than 2.3.0
    .removeHeaders("CamelHttp*")
    .to("otherEndpoint");

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="jetty://http://myhost:9000/myservice/"/> <removeHeaders pattern="CamelHttp*" /> <to uri="otherEndpoint"/> </route> </camelContext>

 

===http://camel.465427.n5.nabble.com/How-long-do-the-camel-headers-live-in-routes-td474477.html

http://camel.465427.n5.nabble.com/Using-properties-or-headers-to-persist-meta-information-on-the-exchange-td4470052.html

You can use exchange properties for this. You do it using
setProperty() instead of setHeader() and they live as long as the
flow.

Headers can be lost at endpoints basically as they usually represent
some component specific things (request headers in http protocol are
different than response headers, so they simply have to be lost).

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值