本文介绍了如何使用MQQueueConnectionFactory设置ApplicationIdData?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图弄清楚使用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://forum.spring.io/forum/spring-projects/integration/jms/97168-how-to-set-wmqconstants-wmq-mqmd-read-enabled-in-spring

http://www.ibm.com/support/knowledgecenter/SSFKSJ_7.0.1/com.ibm.mq.csqzaw.doc/jm41030_.htm

https://www.ibm.com/support/knowledgecenter/zh-CN/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">队列:///Q_Name?targetClient = 1& mdWri‌teEnabled = true& a‌mp; mdMessageContext = ‌1</setHeader>

注意:设置mdWri‌teEnabled = true等于

Note: Setting mdWri‌​teEnabled=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&amp;mdWriteEnabled=true&amp;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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 20:50