MQ

Expand all | Collapse all

How to independently commit your message after processing is done with MQ Get in a different server ?

  • 1.  How to independently commit your message after processing is done with MQ Get in a different server ?

    Posted Mon June 21, 2021 11:21 AM
    My application has multiple services and we dd not want to have multiple IBM Connections for each of the servers. So we have a separate server which interacts with MQ and internally all application services call the MQ Wrapper services to put their messages in corresponding queue. MQ Wrapper services also contains a Queue listener, which has queue name as an input to dequeue FIFO messages and process independently.  The Queue listener service does the following steps. 
    1. Reads the message
    2. Calls the application service to process the message
    3. Commits the message to delete it from the queue. 

    The problem is on the use case when application wants to dequeue a specific message. We call MQ Wrapper service which internally does an MQ Get based on a correlation id and commits the message, and returns the message back to application. Here the problem is that, MQGet and commit are happening in the same service which interfaces with MQ. So if my application crashes, there is a risk of losing the messages altogether, as the message has been already committed as part of MQ Get wrapper service. 

    Is there any possible ways where we can deal with this issue  ?  Thanks in advance



    ------------------------------
    Good Boy
    ------------------------------


  • 2.  RE: How to independently commit your message after processing is done with MQ Get in a different server ?

    Posted Tue June 22, 2021 04:19 AM
    Hello,

    it seems like you have a code design issue rather than an MQ issue, which I think you have already worked out. Your thread that is interacting with MQ is performing the GET and COMMIT without waiting for the code to actually process the message.

    In order to get the behaviour you want, you would need to either move the MQ interactions into the thread doing the work (with a GET before the work and a COMMIT at the end) or you would need to enhance the interaction between the MQ thread and the worker thread so that the initial call just does GET (not COMMIT) and the worker thread requests the MQ thread to COMMIT at some later point. 

    The second way is probably harder because the connection handle that is holding the unit of work open shouldn't be reused until the commit completes as otherwise your commit would be polluted with updates that don't belong together.

    Regards,

    ------------------------------
    Neil Casey
    Senior Consultant
    Syntegrity Solutions
    Melbourne, Victoria
    IBM Champion (Cloud) 2019-21
    ------------------------------



  • 3.  RE: How to independently commit your message after processing is done with MQ Get in a different server ?

    Posted Thu June 24, 2021 04:07 PM
    Perhaps transaction management is pointing to the solution you are looking for.