避免与 RabbitMQ 和 Camel 自动绑定 [英] Avoid automatic binding with RabbitMQ and Camel

查看:26
本文介绍了避免与 RabbitMQ 和 Camel 自动绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 RabbitMQ 与 Camel 一起使用.我正在使用 Camel 2.14.1.

I'm trying to use RabbitMQ with Camel. I am using Camel 2.14.1.

我想在 RabbitMQ 上打开一个扇出交换,然后将队列绑定到它.这似乎工作正常.但是,每次创建 Exchange 时,它​​都会自动绑定到具有系统名称(一个数字)的队列.我不能避免吗?这是一个简单的示例,它向 Exchange 发布 100 条消息.但是它们会被传送到自动创建的队列中,我想避免这种情况.

I want to open an fanout exchange on RabbitMQ and then later bind queues to it. This seems to work fine. However, everytime I create an Exchange, it is automatically bound to queue with a system name (a number). Can't I avoid that? Here is a simple example which posts 100 messages to an Exchange. But they get delivered to an automatically created queue, I want to avoid this.

  @Override
  public void configure() throws Exception
  {
    final String testGUID = "xxxx";
    from("timer://publish?repeatCount=100&period=10&fixedRate=true").process(new Processor()
            //from("timer://publish?repeatCount=100&period=1&fixedRate=true").process(new Processor()

    {
      @Override
      public void process(Exchange _exchange) throws Exception
      {
        String message = String.valueOf(_exchange.getProperty(Exchange.TIMER_COUNTER));
        _exchange.getOut().setBody(message+testGUID);
      }
    })
            .to("rabbitmq://localhost/exchange=logs1237?autoDelete=false&username=guest&password=guest&exchangeType=fanout");

  }

最好的问候,莫滕·克努森

Best regards, Morten Knudsen

更新:从源码看来,如果RabbitMQEndPoint中的队列"不为空,就会触发自动队列.但是队列"会自动分配给String.valueOf(UUID.randomUUID().toString().hashCode());"在施工中.

UPDATE: It seems from looking at the source, that the triggering of the automatic queue happens if "queue" in RabbitMQEndPoint is not null. But "queue" is automatically assigned to "String.valueOf(UUID.randomUUID().toString().hashCode());" at construction.

推荐答案

如果您不想将交换与队列绑定,您可以将声明选项设置为 false.顺便说一句,声明选项是自 Camel 2.14.0 以来新增的.

If you don't want to bind the exchange with queue, you can setup the declare option to be false. BTW, declare option is new added since Camel 2.14.0.

这篇关于避免与 RabbitMQ 和 Camel 自动绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆