簡體   English   中英

Spring應用程序對MQ身份驗證的問題

[英]Spring application to MQ authentification issue

我正在用偵聽器編寫一個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.

如果有任何錯誤,我需要事務管理器將消息放回隊列。 但是由於這個例外,我無法使用它。 請幫助我。

您的transactionManager bean應該引用jmsConnectionFactory而不是mqQueueConnectionFactory。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM