【发布时间】: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