问题
I am new to Mulesoft Anypoint Studio and have just started exploring it. My flow starts with reading messages from MQ and ends with putting it at the destination, to begin with just my local machine and would evolve later. I have run into an issue where the Queue has TSL which involves keystores and truststores. Now, in Anypoint I see WMQ and HTTPS/TSL connectors. I've setup a TSL context as global element but how do I set it as part of WMQ connector? The same queue &/or channel can be accessed by Java code with correct TLS settings (keystores, truststores etc.) but in the studion, I am currently getting this exception:
Root Exception was: MQJE001: An MQException occurred: Completion Code 2, Reason 2009 MQJE016: MQ queue manager closed channel immediately during connect Closure reason = 2009. Type: class com.ibm.mqservices.MQInternalException
I haven't come across any sample code for WMQ with TLS while searching on google. Any clues/insights are greatly appreciated.
Thank you in advance!
回答1:
- Create MQQueueConnectionFactory bean as below
<spring:bean id="MQConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<spring:property name="hostName" value="${hostName}"/>
<spring:property name="port" value="${port}"/>
<spring:property name="channel" value="${channel}"/>
<spring:property name="queueManager" value="${queueManager}"/>
<spring:property name="SSLCipherSuite" value="${SSLCipherSuite}"/>
<spring:property name="targetClientMatching" value="true" />
<spring:property name="transportType" value="1" />
</spring:bean>
- Create UserCredentialsConnectionFactoryAdapter bean and pass above created bean as reference to this.
<spring:bean id="jmsQueueConnectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<spring:property name="targetConnectionFactory" ref="MQConnectionFactory" />
<spring:property name="username" value="${username}" />
<spring:property name="password" value="${password}" />
</spring:bean>
- Create WMQ connector and pass the appropriate references and values
<wmq:connector name="WMQConnector"
hostName="${hostName}"
port="${port}"
queueManager="${queueManager}"
channel="${channel}"
transportType="CLIENT_MQ_TCPIP"
validateConnections="true"
doc:name="WMQ"
password="${password}"
username="${username}"
dynamicNotification="true"
numberOfConsumers="1"
connectionFactory-ref="MQConnectionFactory"
cacheJmsSessions="false"
specification="1.1"
targetClient="JMS_COMPLIANT"
acknowledgementMode="CLIENT_ACKNOWLEDGE"
maxRedelivery="-1">
- Set keystore and truststore locations and passwords in VM arguments as below
-Djavax.net.ssl.trustStore=keystore.jks -Djavax.net.ssl.trustStorePassword=xxxx -Djavax.net.ssl.keyStore=keystore.jks -Djavax.net.ssl.keyStorePassword=xxxx
That's it. This should solve WMQ with SSL integration in Mule.
来源:https://stackoverflow.com/questions/47935332/webmq-with-ssl-in-mulesoft