Camel JMS - Unable to set JMSPriority to IBM MQ Message

守給你的承諾、 提交于 2020-01-06 02:28:13

问题


We are trying to send JMS text message over IBM mq using Apache Camel. We are able set few JMS header properties except the JMSPriority. We tried setting int value and used resultType="java.lang.Integer" but unable to alter priority. Any clue would be more than helpful.

 <route id="mqSender">
                 <from uri="direct:mqSender"></from>
                 <filter>
                       <simple> ${body} != null</simple>
                       <setProperty propertyName="originalRequest">
                              <simple> ${body}</simple>
                       </setProperty>
                       <setHeader headerName="JMSCorrelationID">
                              <simple>${body.messageContextVO.requestID}</simple>
                       </setHeader>
                       <setHeader headerName="VersionId">
                              <simple>${body.metadata["VersionId"]}</simple>
                       </setHeader>
                       <setHeader headerName="FunctionId">
                              <simple>${body.metadata["FunctionId"]}</simple>
                       </setHeader>
                       <setHeader headerName="Format">
                              <simple>${body.metadata["Format"]}</simple>
                       </setHeader>
                       <choice>
                              <when>
                                     <simple>${property.originalRequest.metadata["FetchPriorityValue"]}== "true"</simple>
                                     <transform>
                                            <simple>${body.formattedData}</simple>
                                     </transform>
                                     <setHeader headerName="JMSPriority">
                                           <simple> ${property.originalRequest.priority}</simple>
                                     </setHeader>

                                     <camel:setHeader headerName="CamelJmsDestinationName"><simple>queue:///${property.originalRequest.metadata["queueName"]}?targetClient=1</simple></camel:setHeader>

                              </when>
                       </choice>
                      <log message="${property.originalRequest.metadata[queueName]}"></log>
                       <recipientList>
                              <simple>wmq:queue:${property.originalRequest.metadata["queueName"]}?exchangePattern=InOnly</simple>
                       </recipientList>
                       <transform>
                              <simple>${property.originalRequest}</simple>
                       </transform>
                 </filter>
                 <!-- <to uri="bean:trackerUpdateProcessor?method=process" /> -->
          </route>

回答1:


We found solution to make it work. Priority attribute is required to set at header CamelJmsDestinationName i.e,

<camel:setHeader headerName="CamelJmsDestinationName"><simple>queue:///${property.originalRequest.metadata["queueName"]}?targetClient=1&amp;priority=${dynamicValue}</simple></camel:setHeader>

Sender code checks for value of priority at MQ Destination level in native code. TimeToLive and Priority values needs to set at MQ destination level to work with Camel.




回答2:


I am not sure about wmq, but for normal jms component (and I believe camel wmq behave the same) to set JMSPriority for specific message endpoint configuration must have option "preserveMessageQos" set to true

Set to true, if you want to send message using the QoS settings specified on the message, instead of the QoS settings on the JMS endpoint. The following three headers are considered JMSPriority, JMSDeliveryMode, and JMSExpiration. You can provide all or only some of them. If not provided, Camel will fall back to use the values from the endpoint instead. So, when using this option, the headers override the values from the endpoint. The explicitQosEnabled option, by contrast, will only use options set on the endpoint, and not values from the message header.



来源:https://stackoverflow.com/questions/36399382/camel-jms-unable-to-set-jmspriority-to-ibm-mq-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!