You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by j vh <jv...@hotmail.com> on 2024/02/26 23:13:51 UTC

jms manual acknowledge

Hello,
Using JMS component to consume messages from a queue with the following example code using a pollEnrich:

@Override
public void configure() throws Exception {

   // Exception handling removed to simplify
   from("direct:testRoute")
      .routeId("test1-route-id")
      .loopDoWhile(body().isNotNull())
         .pollEnrich()
         .simple("jms:queue:{{work.queue.name}}")
         .timeout(10000)
         .choice()
            .when(body().isNotNull())
               .setHeader(Exchange.HTTP_METHOD, simple(HttpMethod.POST.name()))
               .setHeader(Exchange.CONTENT_TYPE, simple("application/json; charset=UTF-8"))
               .to("{{rest.api.endpoint}}")
               .process(this::manualAckProcessor)   // I want to ACK the message here
            .endChoice()
         .end()
      .end();
}

The problem is that the pollEnrich consumption of the JMS message also does, depending on component config, either the client acknowledgement or transaction commit immediately.

This is much different than using a regular from() JMS consumer like this, where the consumed message is committed or ack'ed after the end of the route, ie: after the
.to()

   from("jms:queue:{{work.queue.name}}")
      .routeId("test2-route-id")
      .setHeader(Exchange.HTTP_METHOD, simple(HttpMethod.POST.name()))
      .setHeader(Exchange.CONTENT_TYPE, simple("application/json; charset=UTF-8"))
      .to("{{rest.api.endpoint}}")
      .end();

Is there a way to configure or block the pollEnrich from either committing or ack'ing right away?
Can I implement a JMS manual acknowledgement?

thanks,
jvh

ps: using Spring 2.6.2 with Camel 3.18.4