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

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

问题描述

我试图使用RabbitMQ的骆驼。我使用的骆驼2.14.1。

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

我想打开一个的RabbitMQ交换扇出,再后来队列绑定到它。这似乎很好地工作。然而,每次我创建Exchange,它是自动绑定到队列系统名(数字)。我能不能避免?
下面是一个简单的例子,哪些职位100条消息到Exchange。但他们得到传送到自动创建的队列,我想避免这种情况。

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()哈希code());在建设中。

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.

推荐答案

如果您不想绑定队列的交流,你可以设置宣告的选择是错误的。顺便说一句,因为申报骆驼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的骆驼和绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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