Spring 与 WebSphere JMS IBM MQ 提供程序集成

Spring Integration with WebSphere JMS IBM MQ provider

我们有一个 WebSphere JMS Queue 和 QueueConnectionFactory,提供者是 IBM MQ。我们无法直接连接到 IBM MQ。

我有以下配置 - 我有 bean jmsConnectionFactory,它按预期使用 InitialContext 创建工厂。 THE_QUEUE 是我队列的 JNDI 名称

<int-jms:inbound-channel-adapter channel="transformedChannel" connection-factory="jmsConnectionFactory" 
destination-name="THE_QUEUE">
<int:poller fixed-delay="500" />
</int-jms:inbound-channel-adapter>

因错误而失败

Caused by: com.ibm.msg.client.jms.DetailedInvalidDestinationException: JMSWMQ2008: Failed to open MQ queue 'THE_QUEUE'. JMS attempted to perform an MQOPEN, but WebSphere MQ reported an error. Use the linked exception to determine the cause of this error. Check that the specified queue and queue manager are defined correctly.

我的出站通道配置

<int-jms:outbound-channel-adapter id="respTopic" 
connection-factory="jmsConnectionFactory" 
destination-name="THE_REPLYQ" channel="process-channel"/>

如果我使用 java 代码 - 它有效 从 session.createProducer 创建 MessageProducer 并发送消息, 在 queuesession.createConsumer(outQueue) 上创建 MessageConsumer;并接收()

请范您帮忙,关于如何使用 spring 集成和处理消息

为这些队列创建 jms 入站和出站适配器

编辑:

   @Bean
    public ConnectionFactory jmsConnectionFactory(){
        ConnectionFactory connectionFactory = null ;           
        Context ctx = null;         
        Properties p = new Properties();
        p.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
        p.put(Context.PROVIDER_URL, "iiop://hostname.sl");
        p.put("com.ibm.CORBA.ORBInit", "com.ibm.ws.sib.client.ORB");

       try {
            ctx = new InitialContext(p);        
            if (null != ctx)
                System.out.println("Got naming context");
            connectionFactory = (QueueConnectionFactory) ctx.lookup

("BDQCF");
}...


@Bean
public JmsListenerContainerFactory<?> mydbFactory(ConnectionFactory jmsConnectionFactory,
                                                DefaultJmsListenerContainerFactoryConfigurer configurer) {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    configurer.configure(factory, jmsConnectionFactory);

    return factory;
}

代码和配置适用于使用 WebSphere 默认 JMS 提供程序的队列

EDIT2:评论后添加的代码

<int:channel id="jmsInputChannel" />
  <jee:jndi-lookup id="naarconnectionFactory" jndi-name="MQ_QUEUE" resource-ref="false">
   <jee:environment>
      java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory
      java.naming.provider.url=iiop://host.ws
   </jee:environment>
</jee:jndi-lookup>

<int-jms:inbound-channel-adapter id="jmsIn"  channel="jmsInputChannel" 
connection-factory="jmsNAARConnectionFactory" destination-name="naarconnectionFactory">
   <int:poller fixed-delay="500" />
</int-jms:inbound-channel-adapter>

您不能只在那里使用 JNDI 名称 - 您必须执行 JNDI 查找以将其解析为 Destination - 请参阅 Spring JMS Documentation.