首页 > 解决方案 > 使用 spring 集成从 wmq 获取 JMS 目标

问题描述

我正在使用消息驱动通道适配器 (Spring Integration) 使用来自 IBM Mq 的消息。消息中的 JMS Destination 属性为空。有人可以告诉我如何在标题中获取使用 wmq 消费的消息的队列名称。
JMS Destination 属性将用于从 apache Active mq 使用的消息,但不适用于 IBM MQ。

标签: javaspring-integrationibm-mq

解决方案


有这样DefaultJmsHeaderMapper的代码:

 try {
        Destination destination = jmsMessage.getJMSDestination();
        if (destination != null) {
            headers.put(JmsHeaders.DESTINATION, destination);
        }
    }
    catch (Exception ex) {
        this.logger.info("failed to read JMSDestination property, skipping", ex);
    }

因此,如果 IBM Mq 不提供该属性值,我们真的不会有JmsHeaders.DESTINATION关于此事的标题。

我建议您调查消费后获得的所有标头,看看哪些标头可能对您有要求的目的地。

否则,您始终可以在覆盖的方法中扩展DefaultJmsHeaderMapper和实现自己的逻辑。toHeaders()


推荐阅读