简体   繁体   English

Apache Camel RabbitMQ从一个队列到另一个队列

[英]Apache Camel RabbitMQ from queue to queue

I have to implement a micro-service which takes a message from a rabbitmq queue, transform it and push it to a rabbitmq exchange. 我必须实现一个微服务,该服务从rabbitmq队列中获取一条消息,对其进行转换并将其推送到rabbitmq交换。

I am implementing this functionality using Apache Camel RabbitMq and Spring Boot, using Java SDL for Camel. 我正在使用Java CDL使用Apache Camel RabbitMq和Spring Boot来实现此功能。 I am using (for now) a single rabbitmq server, on my machine. 我现在正在机器上使用单个Rabbitmq服务器。 The configuration looks like this: 配置如下所示:

from("rabbitmq://localhost:5672/exchange1?username=guest&password=guest&queue=q1&autoDelete=false");  
.to("rabbitmq://localhost:5672/exchange2?username=guest&password=guest&exchangeType=fanout&skipQueueDeclare=false")

The code anove is getting the message from q1 and it is publishing it again in q1 over and over again. anove代码从q1获取消息,并且一次又一次地在q1中再次发布它。 It works just to get a message from a queue and send it (for example) to file, or create a message separately and publish it to the exchange. 它仅用于从队列中获取消息并将其发送(例如)发送到文件,或者单独创建消息并将其发布到交易所。
Is there any way to make it work as I expect it to do? 有什么方法可以使它像我期望的那样工作?

Thanks 谢谢

The from() generates rabbitMQ headers. from()生成RabbitMQ标头。 Unless you manually remove them, they are passed to your to() . 除非您手动删除它们,否则它们将传递给您的to() This will create a mismatch in your connection. 这将在您的连接中造成不匹配。 Best is to delete the rabbit headers after your from() so they don't interfer in your to() . 最好是在您的from()之后删除Rabbit标头,以免干扰您的to()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM