spring 使用 IBM MQ 启动时出现 TypeMismatchNamingException

TypeMismatchNamingException in spring boot with IBM MQ

我正在尝试创建一个 Spring 引导项目来从队列中读取消息并进行一些处理。

我已经在 application.properties

中定义了 Jndi ConnectionFactory
spring.jms.jndi-name=java:/MyConnectionFactory

启动应用程序时出现以下异常:

Caused by: org.springframework.jndi.TypeMismatchNamingException: Object of type [class com.ibm.mq.connector.outbound.ConnectionFactoryImpl] available at JNDI location [java:/MyConnectionFactory] is not assignable to [javax.jms.ConnectionFactory]

我正在使用给定的 jndi 在 jboss 服务器上部署代码。

不确定在这种情况下 ConnectionFactory 是否需要一些不同的实现。

@Bean public DefaultMessageListenerContainer orderMessageListenerContainer() {
 DefaultMessageListenerContainer endpoint = new DefaultMessageListenerContainer();
 endpoint.setMessageListener(new YourMessageListener());
 endpoint.setDestination("yourDestination");
 endpoint.setConnectionFactory(connectionFactory());
 return orderDefaultJmsListenerContainerFactory().createListenerContainer(endpoint);
}

已使用 DefaultMessageListenerContainer 手动解决。