【问题标题】:How to do jndi lookup of MQ connection factory defined in Websphere app Server from Spring如何从 Spring 中对 Websphere 应用服务器中定义的 MQ 连接工厂进行 jndi 查找
【发布时间】:2013-03-10 21:55:01
【问题描述】:

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

但我找不到合适的连接工厂接口供 MQ 在 Spring 中定义。

但是,当我尝试在 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

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

【问题讨论】:

    标签: spring jndi ibm-mq lookup


    【解决方案1】:

    正确的做法是

    1. 在 Websphere App Server 的队列连接工厂中创建资源(不在连接工厂中)
    2. 在spring config中使用javax.jms.QueueConnectionFactory作为连接工厂

      <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>
      

    这个page 给了我提示。

    【讨论】:

      猜你喜欢
      • 2016-09-23
      • 1970-01-01
      • 1970-01-01
      • 2016-11-16
      • 2014-05-08
      • 1970-01-01
      • 1970-01-01
      • 2022-08-18
      • 2018-08-10
      相关资源
      最近更新 更多