MQ

 View Only
  • 1.  Transactional processing with queues

    IBM Champion
    Posted Fri January 14, 2022 09:50 AM
    I haven't had a chance to code a test yet, but had a few questions about how MQ reacts when multiple consumers are reading from a queue and commit/rollback is being used.  For example, say I have a single instance of Q1 and there are two consumers reading from the queue, C1 and C2.  Normally, each gets a message from the queue in turn until the queue runs out.

    Now, suppose I introduce transactions in this scenario where each consumer behaves as follows:
    1. Get a message with MQGMO_SYNCPOINT set.
    2. Do some work that might take a few seconds (e.g., updating a DB table, invoking REST API, etc).
    3. Execute either commit (CMIT) or rollback (BACK) for the message.  
    There are various timing sequences with how C1 & C2 would interact with the queue.  My questions are:
    • While C1 is waiting to CMIT/BACK a message, is C2 blocked from reading a message, or does it get the next message in line?  Assume the messages are independent and self-contained -- no need to process in sequence.
    • If C1 chooses to rollback a message is it immediately available for C2 or C1 to get again?  
    • Are there special options I should consider when defining the queue that influence the behavior of CMIT and BACK?
    As always thanks for your responses.

    Jim

    ------------------------------
    Jim Creasman
    ------------------------------


  • 2.  RE: Transactional processing with queues

    Posted Fri January 14, 2022 10:12 AM
    Hi Jim, I think the following answer your questions...

    • No it's not blocked, it will get the next available message
    • Yes it's immediately available for C1 or C2 to get again
    • Nothing especially that relates to that basic example. QM attributes such as MAXUMSGS affect how many messages an application can get before it commits the transaction, but nothing on the queue itself.

    Hope that helps, Matt

    ------------------------------
    Matthew Whitehead
    ------------------------------



  • 3.  RE: Transactional processing with queues

    IBM Champion
    Posted Tue January 18, 2022 09:22 AM
    Thanks, Matt!  That's what I needed to know.

    Jim

    ------------------------------
    Jim Creasman
    ------------------------------



  • 4.  RE: Transactional processing with queues

    Posted Tue January 18, 2022 11:07 AM
    Just add to Matthew's answer. It also depends on the queue open option. If C1 has the Q is opened exclusive, then C2 will not be able to do anything until C1 commit and close the Q.

    ------------------------------
    Kwok Tai Yung
    ------------------------------