使用Apache RouteBuilder的Rabbitmq Spring Java配置

时间:2018-08-13 05:15:39

标签: spring-boot rabbitmq

我想用Rabbitmq和apache RouteBuilder配置Spring Boot应用程序,有人可以建议我怎么做

1 个答案:

答案 0 :(得分:3)

您提到Apache骆驼RouteBuiler吗? 如果您说是,则可以使用自版本2.12以来Apache骆驼提供的RabbitMQ component。 有关更多详细信息,请检查我的示例代码:

<!-- language: lang-java -->

@Component
public class MyRoute extends RouteBuilder {
    @Override
    public void configure() throws Exception {
    // listen from exchange and log to console
        from("rabbitmq:topic_logs2?" +
            "vhost=myvhost&hostname=localhost&portNumber=5672" +
            "&username=myname&password=mypassword" +
            "&exchangeType=topic&autoDelete=false&queue=my_queue&routingKey=test.log")
        .log("From RabbitMQ: ${body}");
    }
}