【问题标题】:How to implement the JMS Inbound & Outbound configuration in separate spring integration application?如何在单独的 spring 集成应用程序中实现 JMS Inbound & Outbound 配置?
【发布时间】:2018-06-22 05:38:43
【问题描述】:

我的用例是我们项目中的通知服务实现。

我们已经将 spring 与 jms 一起使用,并且它在休息服务中运行良好。能够使用 JMSTemplate 的 convertAndSend()、convertAndReceive() 函数从一个应用程序向队列发送消息并从另一个应用程序的队列接收消息。

现在我想使用 spring 集成的 java dsl 方法来做到这一点。我们通过在 ActiveMQ 的单个应用程序中使用 Jms 的 inboundGateway() 和 outboundGateway() 做了一个示例。

如何在不同的应用程序中使用spring集成的java dsl只发送/接收消息?

这是我的代码,

@Bean
public IntegrationFlow jmsInboundFlow() {
    return IntegrationFlows
            .from(Jms.inboundGateway(this.connectionFactory)
                    .destination("pan.outbound"))
            .transform((String s) -> s.toUpperCase())
            .channel("in-bound-request-channel")
            .get();
}

@Bean
public IntegrationFlow jmsOutboundGatewayFlow() {
    return IntegrationFlows.from("out-bound-request-channel")
            .handle(Jms.outboundGateway(this.connectionFactory)
                        .requestDestination("pan.outbound"))
            .log()
            .bridge()
            .get();
}

@MessagingGateway
interface EchoGateway {

    @Gateway(requestChannel = "out-bound-request-channel")
    String send(String message);

}

【问题讨论】:

  • 也许这个 Spring Boot 有帮助:spring.io/guides/gs/messaging-jms
  • 谢谢@wwerner。我们只这样做了。我们与spring集成方式有关。
  • 如果您让它在单个应用程序中工作,究竟是什么阻止您将其拆分为 2 个应用程序?应该很简单。
  • @GaryRussell 请查看@我的来源,它工作正常。但它作为一个单一的流程工作。我可以使用休息服务通过网关访问出站。如何单独访问入站?

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


【解决方案1】:

您只需拆分配置 - JMS 入站适配器在一个应用程序中,而 JMS 出站适配器在第二个应用程序中。 方式与一个应用程序中的方式完全相同吗? (也许我错过了一些信息?)

【讨论】:

  • 感谢您的宝贵时间。我想我无法想象这个概念。我已经添加了我的来源,请检查并恢复。
  • 如果您只想访问 inboundGateway,根据您的代码,只需将下一步添加到流程中,例如:.channel("in-bound-request-channel").handle(一些服务)。
  • 谢谢。早些时候我没有完全掌握概念。我已经用带有 jms 轮询消息源的 poller 完成了。
  • @edwin 我从 outboundGateway 改为 outboundAdapter 然后它工作正常。
  • @Alexpandiyan gist.github.com/edwingsm/4b7c764d0f6508552a321503f03ebce2,你能确认一下你做了什么
猜你喜欢
  • 1970-01-01
  • 2017-09-26
  • 1970-01-01
  • 1970-01-01
  • 2016-01-27
  • 1970-01-01
  • 2012-06-14
  • 2011-11-25
  • 2016-02-28
相关资源
最近更新 更多