Uploaded image for project: 'AMQ Clients'
  1. AMQ Clients
  2. ENTMQCL-2034

[cpp] Best practice to handle message acknowledgements in a multithreaded environment

XMLWordPrintable

      Customer is attempting to modify an existing program that used the AMQ C++ API, to use the AMQ Proton C++ Library as seems to be the preferred method with AMQ Artemis.

      He is running into trouble trying to handle message acknowledgements in a multi threaded environment and was wondering what the best practices for doing so are.

      Using the sample code provided at: https://access.redhat.com/documentation/en-us/red_hat_amq/7.0/html-single/using_the_amq_cpp_client/index#acknowledging_received_messages

      As well as the examples provided at: https://qpid.apache.org/releases/qpid-proton-0.30.0/proton/cpp/examples/multithreaded_client.cpp.html

      His issue stems from the proton::delivery object being available only in the on_message function. This implies that the message must be accepted in that function. Unfortunately this negates the ability to read several messages and process them prior to acknowledging them.

      Essentially what he is doing with the AMQ C++ API and hoping to recreate with Proton is the following:

      1. Read messages off 1 or more queues.
      2. Place these messages into an internal work queue that is handled by a pool of threads.
      3. Acknowledge the messages only after they are processed to ensure nothing is lost.

            cjansen@redhat.com Cliff Jansen
            rhn-support-cpandey Chandra Shekhar Pandey (Inactive)
            Dominik Stuchlík Dominik Stuchlík (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: