【问题标题】:Spring Integration writing to IBM MQSpring Integration 写入 IBM MQ
【发布时间】:2020-05-06 05:09:04
【问题描述】:

使用 Boot 2.2.2 和 Spring Integration 5.2.2 通过 IBM MQ Series 9 与另一个应用程序交互;消息必须是纯文本(不是 JMS)。 SI 可以正确获取文本消息,但是如果没有 JMS 标头,我似乎无法放入 MQ。

使用JMS 没有 SI,我可以使用写纯文本消息;

    jmsTemplate.send(myQueue, new MessageCreator() {

        @Override
        public Message createMessage(Session session) throws JMSException {
            return session.createTextMessage(message);
        }
    });

使用 SI 时,我有以下几点;

    @Bean
    public IntegrationFlow toQueue(
            ConnectionFactory connectionFactory, 
            @Value("${app.outQueue}") String myQueue
    ) {
        return IntegrationFlows
            .from("myIncomingChannel")
            .headerFilter("*")
            .handle(
                Jms
                    .outboundAdapter(connectionFactory)
                    .configureJmsTemplate(jts -> jts.jmsMessageConverter(new SimpleMessageConverter()))
                    .extractPayload(true)
                    .destination(myQueue)
            )
            .get();
    }

我已经尝试了 8 种组合;

  1. 有/无configureJmsTemplate
  2. extractPayload 对或错。
  3. 有/无headerFilter

所有测试都会在队列中给我一条 JMS 消息。如何让 SI JMS 编写纯文本消息?

【问题讨论】:

    标签: spring-integration spring-jms spring-integration-dsl


    【解决方案1】:

    我使用这篇帖子How to remove default Spring JMS Template headers when sending a message to an MQ? 的答案解决了这个问题

    工作版本是;

    .handle(
       Jms
          .outboundAdapter(connectionFactory)
          .destination("queue:///" + myQueue + "?targetClient=1")
       )
    .get();
    

    【讨论】:

    • @ArtemBilam 两天后,当这个网站允许我时:-)
    猜你喜欢
    • 1970-01-01
    • 2015-11-06
    • 2014-08-28
    • 2017-09-10
    • 2020-09-29
    • 2018-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多