Camel RaabitMQ Acknowledgement

让人想犯罪 __ 提交于 2019-12-02 07:55:51

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

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?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!