【问题标题】:TypeMismatchNamingException in spring boot with IBM MQ使用 IBM MQ 的 Spring Boot 中的 TypeMismatchNamingException
【发布时间】:2019-03-15 14:53:41
【问题描述】:

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

我在 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 是否需要一些不同的实现。

【问题讨论】:

    标签: spring-boot jboss ibm-mq spring-jms


    【解决方案1】:
    @Bean public DefaultMessageListenerContainer orderMessageListenerContainer() {
     DefaultMessageListenerContainer endpoint = new DefaultMessageListenerContainer();
     endpoint.setMessageListener(new YourMessageListener());
     endpoint.setDestination("yourDestination");
     endpoint.setConnectionFactory(connectionFactory());
     return orderDefaultJmsListenerContainerFactory().createListenerContainer(endpoint);
    }
    

    使用 DefaultMessageListenerContainer 手动解决。

    【讨论】:

    • 我尝试对您的代码进行一些格式化,但如果您编辑答案,您可以将原始答案粘贴在两行之间,并在其上仅使用 ```,这将允许它按您想要的方式间隔它(固定宽度字体)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-15
    • 2021-09-25
    • 2019-06-16
    • 1970-01-01
    • 1970-01-01
    • 2018-09-29
    相关资源
    最近更新 更多