从Spring如何在Websphere App Server中定义的MQ连接工厂的jndi查找 [英] How to do jndi lookup of MQ connection factory defined in Websphere app Server from Spring

查看:130
本文介绍了从Spring如何在Websphere App Server中定义的MQ连接工厂的jndi查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to connect to a MQ connection factory defined in Websphere app Server 7.0.

但是我找不到合适的connectionfactory接口供MQ在Spring中定义.

But I couldnt find a right connectionfactory interface for the MQ to define in Spring.

但是,当我尝试在spring config文件中对连接详细信息进行硬编码时,我能够连接到队列管理器.

However when I tried to hardcode the connection details in the spring config file, I am able to connect to the Queue Manager.

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

What is the right interface/format to use in Spring beans to load the MQ connection factory defined in Websphere appl server?

工作代码

<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连接工厂

where WASQM is the MQ connection factory defined in Websphere

无法正常工作的代码出现错误

 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 App服务器-7.0

I need help in replacing the not working code with a right code. Spring - 3.0.5 IBM MQ and Web App Servers - 7.0

推荐答案

正确的方法是

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

  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>

页面给了我提示.

这篇关于从Spring如何在Websphere App Server中定义的MQ连接工厂的jndi查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆