简体   繁体   English

Spring应用程序对MQ身份验证的问题

[英]Spring application to MQ authentification issue

I'm writing a java app with a Listener to read messages from WebSphere MQ. 我正在用侦听器编写一个Java应用程序,以从WebSphere MQ中读取消息。

Here's my applicationContext.xml: 这是我的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>

This is what causing problems: 这是导致问题的原因:

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

If I remove this property everything work fine. 如果删除此属性,一切正常。 Messages from my queue are read. 从我的队列中读取消息。 But if I put this property I got the following error: 但是,如果我放置此属性,则会出现以下错误:

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.

I need transaction manager to put message back to the queue if there's any errors. 如果有任何错误,我需要事务管理器将消息放回队列。 But i can't use it due this exception. 但是由于这个例外,我无法使用它。 Help me pls. 请帮助我。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM