如何使用 MQQueueConnectionFactory 设置 ApplicationIdData? [英] How to set ApplicationIdData using MQQueueConnectionFactory?
问题描述
试图找出使用 JMS 设置 ApplicationIdData 的骆驼/Spring 配置.
Trying to figure out the camel/Spring configuration to set ApplicationIdData using JMS.
我知道如下的java方法,我使用下面的设置MQOO_SET_IDENTITY_CONTEXT
I know the java way to do it as below, I set MQOO_SET_IDENTITY_CONTEXT using below
int putOptions = MQConstants.MQPMO_SET_IDENTITY_CONTEXT;
pmo.options =putOptions;
然后我将 applicationIdData 设置为:
and then i set applicationIdData as:
MQMessage msg = new MQMessage();
msg.applicationIdData = "SomeId";
msg.writeString(qmessage);
queue.put(msg, pmo);
queue.put(msg, pmo);
问题是,如何使用 JMS/camel/Spring 配置设置 applicationIdData.以下是我目前的骆驼配置.
Question is, How do I set applicationIdData using JMS/camel/Spring configuration. Below is my current camel configuration.
<bean class="org.apache.camel.component.jms.JmsComponent" id="jmsConnection">
<property name="connectionFactory" ref="mqConnectionFactoryWrapper" />
<property name="acknowledgementModeName" value="AUTO_ACKNOWLEDGE" />
</bean>
<bean id="connectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="hostName" value="${HOSTMNAME}" />
<property name="port" value="${PORT}" />
<property name="queueManager" value="${MQ_QMNAME}" />
<property name="channel" value="${MQ_INTERNAL_CHANNEL}" />
<property name="transportType" value="1" />
<!-- Transport type 1 means pure TCP/IP without any local client -->
</bean>
<bean id="mqConnectionFactoryWrapper"
class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="connectionFactory" />
<property name="sessionCacheSize" value="500" />
</bean>
<bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="mqConnectionFactoryWrapper" />
</bean>
<bean id="PROPAGATION_REQUIRES_NEW"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionManager" ref="jmsTransactionManager" />
<property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW" />
</bean>
我浏览了以下链接,找不到正确答案
I have gone through below links, couldnt find the right answer
http://www.ibm.com/support/knowledgecenter/SSFKSJ_7.0.1/com.ibm.mq.csqzaw.doc/jm41030_.htm
https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.0.0/com.ibm.mq.dev.doc/q032010_.htm
推荐答案
我需要在骆驼配置中找到一种方法来在目标中设置一些属性并设置一些标题.我在标题中将目的地设置为
All I needed to find a way in camel config to set some properties in the destination and set some header. I set destination in the header as
<setHeader headerName="CamelJmsDestinationName"> queue:///Q_Name?targetClient=1&mdWri teEnabled=true&a mp;mdMessageContext= 1</setHeader>
注意:设置 mdWri teEnabled=true 等于
Note: Setting mdWriteEnabled=true is equal to
// Enable MQMD write
dest.setBooleanProperty(WMQConstants.WMQ_MQMD_WRITE_ENABLED, true);
设置 mdMessageContext= 1 等于
Setting mdMessageContext=1 is equal to
// Optionally, set a message context if applicable for this MD field
dest.setIntProperty(WMQConstants.WMQ_MQMD_MESSAGE_CONTEXT,
WMQConstants.WMQ_MDCTX_SET_IDENTITY_CONTEXT);
然后将 ApplicationIdData 设置为<setHeader headerName="JMS_IBM_MQMD_ApplIdentityData" > BSI_XML_CANADA_ACK BSI_XML_CANADA_ACK </setHeader>
Then set ApplicationIdData as <setHeader headerName="JMS_IBM_MQMD_ApplIdentityData" > BSI_XML_CANADA_ACK BSI_XML_CANADA_ACK </setHeader>
完整代码:
<route id="ValidateAndAck" streamCache="true">
<from uri="sql:{{ValidateCDMsg}}" />
<setHeader headerName="CamelJmsDestinationName"> <constant>queue:///Q_Name?targetClient=1&mdWriteEnabled=true&mdMessageContext=1</constant></setHeader>
<setHeader headerName="mdWriteEnabled"> <simple>true</simple></setHeader> <!-- This may be redundant-->
<setHeader headerName="mdMessageContext"> <simple>2</simple></setHeader> <!-- This may be redundant-->
<setHeader headerName="JMS_IBM_MQMD_ApplIdentityData" >
<simple>APP_ID_NAME</simple>
</setHeader>
<setHeader headerName="JMS_IBM_MQMD_ApplOriginData" >
<simple>APP_ID_NAME</simple>
</setHeader>
<to uri="bean:ProcessBean?method=setProcessId" />
我不确定是否需要 JMS_IBM_MQMD_ApplOriginData.
I am not sure that JMS_IBM_MQMD_ApplOriginData is required.
这篇关于如何使用 MQQueueConnectionFactory 设置 ApplicationIdData?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!