6

我正在尝试连接到 Websphere app Server 7.0 中定义的 MQ 连接工厂。

但是我找不到在 Spring 中定义 MQ 的正确 connectionfactory 接口。

但是,当我尝试在 spring 配置文件中硬编码连接详细信息时,我能够连接到队列管理器。

在 Spring bean 中使用什么正确的接口/格式来加载 Websphere appl 服务器中定义的 MQ 连接工厂?

工作代码

<bean id="mqConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
    <property name="hostName">
        <value>127.0.0.1</value>
    </property>
    <property name="port">
        <value>1414</value>
    </property>
    <property name="queueManager">
        <value>MYQM</value>
    </property>
    <property name="transportType">
        <value>1</value>
    </property>
</bean>

不工作的代码

<bean id="mqConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jms/WASQM"/>
    <property name="lookupOnStartup" value="false"/>
    <property name="cache" value="true" />
    <property name="proxyInterface"  value="com.ibm.mq.jms.MQQueueConnectionFactoryFactory" />
</bean>

其中 WASQM 是 Websphere 中定义的 MQ 连接工厂

非工作代码错误

 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mqConnectionFactory' defined in ServletContext resource [/WEB-INF/config/config-mq.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: [com.ibm.mq.jms.MQQueueConnectionFactoryFactory] is not an interface
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
Caused by: java.lang.IllegalArgumentException: [com.ibm.mq.jms.MQQueueConnectionFactoryFactory] is not an interface

我需要帮助来用正确的代码替换不工作的代码。Spring - 3.0.5 IBM MQ 和 Web 应用服务器 - 7.0

4

1 回答 1

4

Right way to do is

  1. Create the resource in Queue Connection Factory in Websphere App Server (not in Connection Factory)
  2. Use javax.jms.QueueConnectionFactory as the connection factory in spring config

    <bean id="mqConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
       <property name="jndiName" value="WASQM"/>
       <property name="lookupOnStartup" value="false"/>
       <property name="cache" value="true" />
       <property name="proxyInterface"  value="javax.jms.QueueConnectionFactory" />
    </bean>
    

This page gave me the hint.

于 2013-03-22T10:41:41.190 回答