我的用例是在我们的项目中实现通知服务。
我们将 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);
}
最佳答案
您只需拆分配置 - 一个应用程序中的 JMS 入站适配器和第二个应用程序中的 JMS 出站适配器。 和一个应用程序中的方式完全一样吗? (也许我错过了一些信息?)
关于java - 如何在单独的 Spring 集成应用程序中实现 JMS 入站和出站配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50981305/