Apache camel的Spring RabbitMQ的RabbitMQ队列中没有可用的消息

lp0sw83n  于 8个月前  发布在  Apache
关注(0)|答案(1)|浏览(67)

当我尝试使用Apache camel组件的Spring RabbitMQ将消息从一个队列发布到另一个队列时,目标队列不会获得任何消息。

@Component
public class WeatherRoute extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        fromF(RABBIT_URI,"weather","weather")
       .toF(RABBIT_URI,"weather_event","weather_event")
 }
}

字符串
这是我的配置组件:

@Configuration
public class CamelConfiguration {
    public static final String RABBIT_URI="spring-rabbitmq:amq.direct?exchangeType=direct&queues=%s&routingKey=%s";

    @Bean 
    // auto injected because we name it with rabbitConnectionFactory
    public ConnectionFactory rabbitConnectionFactory() {
       //define a connectionFactory
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("localhost");
        factory.setPort(5672);
        factory.setUsername("guest");
        factory.setPassword("guest");
        return factory;
    }

}


我已经使用RabbitMQ接口手动创建了两个队列,但问题仍然存在

8oomwypt

8oomwypt1#

对于RabbitMQ:https://camel.apache.org/components/3.21.x/rabbitmq-component.html的这种Apache Camel URI,似乎没有queues参数。
我建议使用不同的URI:基于queue的消费者端和基于routingKey的生产者端。这就是AMQP协议的工作原理。

相关问题