Camel RaabitMQ Acknowledgement

后端 未结 2 1595
梦如初夏
梦如初夏 2021-01-24 18:08

I am using Camel for my messaging application. In my use case I have a producer (which is RabbitMQ here), and the Consumer is a bean.

from(\"rabbitmq://127.0.0.1         


        
相关标签:
2条回答
  • 2021-01-24 18:53

    You can consider to use the camel AsyncProcessor API to call the callback done once you processing the message from BlockingQueue.

    0 讨论(0)
  • 2021-01-24 18:58

    I bumped into the same issue.

    The Camel RabbitMQConsumer.RabbitConsumer implementation does

    consumer.getProcessor().process(exchange);
    
    long deliveryTag = envelope.getDeliveryTag();
    if (!consumer.endpoint.isAutoAck()) {
      log.trace("Acknowledging receipt [delivery_tag={}]", deliveryTag);
      channel.basicAck(deliveryTag, false);
    }
    

    So it's just expecting a synchronous processor. If you bind this to a seda route for instance, the process method returns immediately and you're pretty much back to the autoAck situation.

    My understanding is that we need to make our own RabbitMQ component to do something like

    consumer.getAsyncProcessor().process(exchange, new AsynCallback() {
      public void done(doneSync) {
        if (!consumer.endpoint.isAutoAck()) {
          long deliveryTag = envelope.getDeliveryTag();
          log.trace("Acknowledging receipt [delivery_tag={}]", deliveryTag);
          channel.basicAck(deliveryTag, false);
        }
      }
    });
    

    Even then, the semantics of the "doneSync" parameter is not clear to me. I think it's merely a marker to identify whether we're dealing with a real async processor or a synchronous processor that was automatically wrapped into an async one.

    Maybe someone can validate or invalidate this solution?

    Is there a lighter/faster/stronger alternative?

    Or could this be suggested as the default implementation for the RabbitMQConsumer?

    0 讨论(0)
提交回复
热议问题