【问题标题】:Spring application to MQ authentification issueSpring 应用程序到 MQ 身份验证问题
【发布时间】:2014-11-25 06:02:15
【问题描述】:

我正在编写一个带有侦听器的 Java 应用程序来读取来自 WebSphere MQ 的消息。

这是我的 applicationContext.xml:

<bean id="transactionManager"
    class="org.springframework.jms.connection.JmsTransactionManager">
    <property name="connectionFactory" ref="mqQueueConnectionFactory" />
</bean>

<bean id="mqMessageListener" class="ru.mos.notification.controller.MQNotificationListener">
    <property name="mqwsUrl" value="${mqws.url}" />
    <property name="mqwsSoapAction" value="${mqws.soapAction}" />
    <property name="mqwsSoapStart" value="${mqws.soapStart}" />
    <property name="mqwsSoapEnd" value="${mqws.soapEnd}" />
</bean>

<bean id="mqQueueConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
    <property name="hostName" value="${mq.hostName}" />
    <property name="port" value="${mq.port}" />
    <property name="queueManager" value="${mq.queueManager}" />
    <property name="transportType" value="1" />
    <property name="channel" value="${mq.channel}" />
</bean>

<bean id="jmsConnectionFactory"
    class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
    <property name="targetConnectionFactory" ref="mqQueueConnectionFactory" />
    <property name="username" value="${mq.username}" />
    <property name="password" value="${mq.password}" />
</bean>

<bean
    class="org.springframework.jms.listener.DefaultMessageListenerContainer">       
    <property name="destinationName" value="${mq.destinationName}" />
    <property name="destinationResolver">
        <bean
            class="org.springframework.jms.support.destination.DynamicDestinationResolver" />
    </property>
    <property name="sessionAcknowledgeModeName" value="AUTO_ACKNOWLEDGE" />
    <property name="sessionTransacted" value="true" />
    <property name="messageListener" ref="mqMessageListener" />
    <property name="transactionManager" ref="transactionManager"/>
    <property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>

这是导致问题的原因:

<property name="transactionManager" ref="transactionManager"/>

如果我删除此属性,一切正常。我的队列中的消息被读取。但是如果我把这个属性我得到以下错误:

17:54:20,468  WARN DefaultMessageListenerContainer:821 - Setup of JMS message listener invoker failed for destination 'asurtst1qu' - trying to recover. Cause: Could not create JMS transaction; nested exception is com.ibm.msg.client.jms.DetailedJMSSecurityException: JMSWMQ2013: The security authentication was not valid that was supplied for QueueManager 'asurtst1mgr' with connection mode 'Client' and host name '172.31.197.247(1414)'. Please check if the supplied username and password are correct on the QueueManager you are connecting.

如果有任何错误,我需要事务管理器将消息放回队列。但由于这个例外,我不能使用它。请帮帮我。

【问题讨论】:

  • 在队列管理器错误日志 (AMQERR01.LOG) 中发现的错误是什么。如果您连接到 qmgr 版本 7 及以下版本,请尝试从 jmsConnectionFactory 中删除用户和密码。

标签: java spring jms ibm-mq


【解决方案1】:

您的 transactionManager bean 应该引用 jmsConnectionFactory 而不是 mqQueueConnectionFactory。

【讨论】:

    猜你喜欢
    • 2015-08-03
    • 1970-01-01
    • 2022-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-13
    • 2019-04-08
    • 1970-01-01
    相关资源
    最近更新 更多