SpringJMS 3.0.4未使用UserName连接MQ 7.5连接
无法使用用户名从Spring JMS 3.0.4版连接MQ 7.5队列管理器。传递用户名以提供对队列的适当授权。我们正在使用SpringJMS,它使用同一台机器上可用的MQ Client库。 MQ Manager / Server在远程计算机上
以下是我们正在使用的配置,但我们收到错误消息,如下所示
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jms="http://www.springframework.org/schema/jms" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd">
<!-- :: Messaging Infrastructure Beans :: -->
<bean id="transport" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" p:staticField="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP" />
<bean id="mqConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory" p:transportType-ref="transport"
p:queueManager="${tcs.messaging.queueManager.name}" p:hostName="${tcs.messaging.queueManager.host}" p:port="${tcs.messaging.queueManager.port}"
p:channel="${tcs.messaging.queueManager.channel}" />
<bean id="queueConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory"
p:targetConnectionFactory-ref="mqConnectionFactory" p:sessionCacheSize="${tcs.messaging.connectionFactory.sessionCacheSize}"
p:exceptionListener-ref="providerMessageListener" />
<bean id="providerMessageListener" class="com.uhg.treasury.customerservice.management.transport.jms.ProviderExceptionListener" />
<!-- New Addition :: -->
<bean id="myConnectionFactory2" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory"> <ref bean ="mqConnectionFactory"/> </property>
<property name="username"> <value>"tbossmqd"</value> </property>
<property name="password"> <value>"password1"</value> </property>
</bean>
</beans>
错误消息如下
2014-06-27 11:25:42,503 [main] DEBUG - DefaultMessageListenerContainer.establishSharedConnection(752)|无法建立共享JMS连接 - 将其留给异步调用者以尽快建立连接 com.ibm.msg.client.jms.DetailedJMSSecurityException:JMSWMQ2013:为QueueManager提供的安全认证无效&#39; WMQT013&#39;使用连接模式&#39;客户端&#39;和主机名&#39; wmqlt0006.xxx.com(1960)&#39;。 请检查所连接的QueueManager上提供的用户名和密码是否正确。 在com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:521) 在com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:221) 在com.ibm.msg.client.wmq.internal.WMQConnection。(WMQConnection.java:426) at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:6902) at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:6277) at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createConnection(JmsConnectionFactoryImpl.java:285) at com.ibm.mq.jms.MQConnectionFactory.createCommonConnection(MQConnectionFactory.java:6233) 在com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:120) at com.ibm.mq.jms.MQQueueConnectionFactory.createConnection(MQQueueConnectionFactory.java:203) 在org.springframework.jms.connection.SingleConnectionFactory.doCreateConnection(SingleConnectionFactory.java:342) 在org.springframework.jms.connection.SingleConnectionFactory.initConnection(SingleConnectionFactory.java:288) 在org.springframework.jms.connection.SingleConnectionFactory.createConnection(SingleConnectionFactory.java:225) 在org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184) 在org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:403) 在org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:371) 在org.springframework.jms.listener.DefaultMessageListenerContainer.establishSharedConnection(DefaultMessageListenerContainer.java:749) 在org.springframework.jms.listener.AbstractJmsListeningContainer.doStart(AbstractJmsListeningContainer.java:278) 在org.springframework.jms.listener.AbstractJmsListeningContainer.start(AbstractJmsListeningContainer.java:263) 在org.springframework.jms.listener.DefaultMessageListenerContainer.start(DefaultMessageListenerContainer.java:555) 在org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:166) 在org.springframework.context.support.DefaultLifecycleProcessor.access $ 1(DefaultLifecycleProcessor.java:154) 在org.springframework.context.support.DefaultLifecycleProcessor $ LifecycleGroup.start(DefaultLifecycleProcessor.java:335) 在org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:143) 在org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:108) 在org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:908) 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:428) 在org.springframework.context.support.ClassPathXmlApplicationContext。(ClassPathXmlApplicationContext.java:197) 在org.springframework.context.support.ClassPathXmlApplicationContext。(ClassPathXmlApplicationContext.java:172) 在org.springframework.context.support.ClassPathXmlApplicationContext。(ClassPathXmlApplicationContext.java:158) 在com.uhg.treasury.customerservice.management.Server。(Server.java:61) 在com.uhg.treasury.customerservice.management.Server。(Server.java:43) 引起:com.ibm.mq.MQException:JMSCMQ0001:WebSphere MQ调用失败,包含compcode&#39; 2&#39; (&#39; MQCC_FAILED&#39;)原因&#39; 2035&#39; (&#39; MQRC_NOT_AUTHORIZED&#39)。 在com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:209) ......还有29个 2014-06-27 11:25:42,512 [main] DEBUG - AbstractJmsListeningContainer.resumePausedTasks(539)|恢复暂停的任务:org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker@627a94a9 2014-06-27 11:25:42,512 [main] DEBUG - AbstractJmsListeningContainer.resumePausedTasks(539)|恢复暂停的任务:org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker@5db615c1
答案 0 :(得分:2)
我可以确认Spring调用的MQQueueuConnectionFactory.createConnection
方法是没有通过用户名/密码的版本。这就是您看到MQRC_NOT_AUTHORIZED的原因,因为用户名没有传递给队列管理器。
我不是Spring专家,但我相信你添加的新myConnectionFactory2 bean需要引用你的CachingConnectionFactory bean(queueConnectionFactory),而不是直接引用MQQueueConnectionFactory bean(mqConnectionFactory)。所以改变这个:
<bean id="myConnectionFactory2" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory"> <ref bean ="mqConnectionFactory"/> </property>
<property name="username"> <value>"tbossmqd"</value> </property>
<property name="password"> <value>"password1"</value> </property>
</bean>
是这样的:
<bean id="myConnectionFactory2" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory"> <ref bean ="queueConnectionFactory"/> </property>
<property name="username"> <value>"tbossmqd"</value> </property>
<property name="password"> <value>"password1"</value> </property>
</bean>