Spring集成-通道适配器与网关(AMQP)
我对spring集成中通道适配器和网关的区别感到困惑。如@gary russell中所述,通道适配器是非定向的,而网关是双向的。如果是这种情况,为什么会有amqp入站网关和amqp出站网关 我最终要完成的是以下几点:Spring集成-通道适配器与网关(AMQP),spring,rabbitmq,spring-integration,amqp,spring-amqp,Spring,Rabbitmq,Spring Integration,Amqp,Spring Amqp,我对spring集成中通道适配器和网关的区别感到困惑。如@gary russell中所述,通道适配器是非定向的,而网关是双向的。如果是这种情况,为什么会有amqp入站网关和amqp出站网关 我最终要完成的是以下几点: 在控制器内接收到Http请求 将消息放在amqp队列上 使用者使用消息并将结果放入结果队列 结果到达控制器 所以我想我需要一个网关,它有一个从控制器调用的接口,将有效负载放入amqp队列(配置为其请求通道),同时它在应答通道上侦听其应答。 然而,在这种配置下,我总是以 Messag
MessageDeliveryException: Dispatcher has no subscribers for channel 'application.fromRabbit'
其中fromRabibbit是我的回复队列。在询问此类问题时,应始终显示配置 调度程序没有订户… 这是一个配置错误,您没有正确连接集成流 Spring集成中有两种类型的网关- 与外部系统接口的网关 它们为外部系统提供请求/应答语义 入站网关用于服务器端请求/应答,其中服务器接收请求、执行某些处理并返回应答 出站网关是客户端的等价物,客户端发送请求并等待回复。使用AMQP,我们有一个异步版本,其中回复返回到另一个线程 消息网关 这些基于接口的网关从Java代码(而不是某些外部系统)提供网关(通常是请求/应答,但具有无效结果的方法是单向的) 这使遗留java代码能够使用基于集成的流 所以你可能
controller -> gateway -> transformer(optional) -> amqp-outbound-gateway
…这是一种常见的模式,效果很好
服务器端可能是
amqp-inbound-gateway -> service-activator
显示您的代码/配置,有人可以帮助调试您的配置问题。谢谢@gary russell提供的见解。我想我现在有了正确的配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-amqp="http://www.springframework.org/schema/integration/amqp"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xsi:schemaLocation="http://www.springframework.org/schema/integration/amqp http://www.springframework.org/schema/integration/amqp/spring-integration-amqp.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 'CLIENT' SIDE CONFIG -->
<int:channel id="clientToRabbit" />
<int:channel id="clientFromRabbit" />
<int:gateway id="uppercaseGateway" service-interface="com.example.queuing.UpperCaseService" default-request-channel="clientToRabbit" />
<int-amqp:outbound-gateway request-channel="clientToRabbit" amqp-template="amqpTemplate" exchange-name="si.test.exchange" routing-key="si.test.binding" />
<!-- 'SERVER' SIDE CONFIG -->
<int:channel id="serverFromRabbit" />
<int:channel id="serverToRabbit" />
<int-amqp:inbound-gateway request-channel="serverFromRabbit" reply-channel="serverToRabbit" queue-names="si.test.queue" amqp-template="amqpTemplate" connection-factory="connectionFactory" />
<int:service-activator input-channel="serverFromRabbit" output-channel="serverToRabbit" ref="upperCaseService" method="toUpperCase" />
<!-- Infrastructure -->
<rabbit:connection-factory id="connectionFactory" host="localhost" />
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory" />
<rabbit:admin connection-factory="connectionFactory" />
<rabbit:queue name="si.test.queue" />
<rabbit:direct-exchange name="si.test.exchange">
<rabbit:bindings>
<rabbit:binding queue="si.test.queue" key="si.test.binding" />
</rabbit:bindings>
</rabbit:direct-exchange>
</beans>