137.11. 请求/重新请求
支持使用 RabbitMQ 直接回复对 请求和回复 消息传递。
以下示例确实请求/回复,其中消息是使用 cheese Exchange name 和路由密钥 foo.bar 发送的消息(由第二第二 Camel 路由使用),这会添加带有 'Hello ' 的消息,然后发回消息。
因此,如果我们将 World
作为消息正文发送到 direct:start,则可以看到正在记录的消息
- log:request TOKEN World
- log:input TOKEN World
- log:response swig Hello World
from("direct:start") .to("log:request") .to(ExchangePattern.InOut, "spring-rabbitmq:cheese?routingKey=foo.bar") .to("log:response"); from("spring-rabbitmq:cheese?queues=myqueue&routingKey=foo.bar") .to("log:input") .transform(body().prepend("Hello "));
from("direct:start")
.to("log:request")
.to(ExchangePattern.InOut, "spring-rabbitmq:cheese?routingKey=foo.bar")
.to("log:response");
from("spring-rabbitmq:cheese?queues=myqueue&routingKey=foo.bar")
.to("log:input")
.transform(body().prepend("Hello "));