MQ

 View Only
  • 1.  Websphere MQ Realtime and Restart :: MQ Get Operation

    Posted Wed May 10, 2023 02:10 AM

    Hi Team,

    We have the following requirement Can you please help us to get the solution?

    We want to run the get messages operation continuously, we are able to do it with the below operation. The task is continuously and it's reading every new message. we are able to achieve realtime data read.

    our requirement is if this real-time operation fails for any reason 

     EX: we have 500 messages and we run the real-time job, it reads all the 500 messages and if we add a new message, it will read a new message also and it keeps running(a total of 501 messages are read). If this Job fails for any reason and If we restart this job, the Job should start reading from 502 instead of all messages. 

    How to achieve this? Can you please help us here? we are using the following jars






    ------------------------------
    Ranjitha YM
    ------------------------------


  • 2.  RE: Websphere MQ Realtime and Restart :: MQ Get Operation

    Posted Wed May 10, 2023 02:48 AM

    What is the java code for this



    ------------------------------
    Ranjitha YM
    ------------------------------



  • 3.  RE: Websphere MQ Realtime and Restart :: MQ Get Operation

    Posted Thu May 11, 2023 03:48 AM
    Edited by Francois Brandelik Thu May 11, 2023 03:57 AM

    Why are you using a non destructive MQGET (Browse) in the options.
    You should be using a destructive MQGET and Syncpoint (units of work) (you do a manager.commit() but did not enable syncpoint in the gmo options...!
    If you need to have multiple programs get the same message think about streaming queues (MQ 9.3) or Pub/Sub model.

    You do get that the MQMD will change after the MQGET call. Just to be on the safe side consider that some gmo values may change after the MQGET call. So I would create a constant and for each iteration in the loop reapply the constant to the variable. Creating a new MQMessage for each iteration is right.

    ------------------------------
    Francois Brandelik
    ------------------------------



  • 4.  RE: Websphere MQ Realtime and Restart :: MQ Get Operation

    IBM Champion
    Posted Thu May 11, 2023 01:55 PM
    Edited by Roger Lacroix Thu May 11, 2023 01:56 PM

    There are several problems/issues with what you are asking.  Also, in the future, just post your code and then tag the code using the 'code' tag rather than posting a screenshot.

    First, you do realize that if another consumer is performing a destructive get on the same queue then your application may never get to see that particular message. There are several ways for MQ or an API Exit to duplicate every message to another queue (backup queue). (1) Pub/Sub, (2) Stream queue (9.3) or a vendor product like MQ Message Replication.

    As FB pointed out, there are 2 types of MQGET operations: non-destructive get (browse) and destructive get.

    Third, the MQ JAR files you listed are not the complete/required list of MQ JAR files for a Java (non-JMS) application.  You should use the com.ibm.mq.allclient.jar file as it is self-contained and was first available in IBM MQ v8.0.

    Four, nothing in MQ will allow you to resume consuming messages at a particular message (i.e. 501) of a queue.  You would need to code this.

    Fifth, how often does your application crash or suddenly stop working? Because this is a simple type of application and should not be crashing.

    Sixth, you haven't said what problem you are trying to solve. I can suggest several solutions, but without the context of your problem, I cannot give you a proper answer.



    ------------------------------
    Roger Lacroix
    CTO
    Capitalware Inc.
    London ON Canada
    https://capitalware.com
    ------------------------------



  • 5.  RE: Websphere MQ Realtime and Restart :: MQ Get Operation

    Posted Fri May 12, 2023 05:29 AM
    Edited by Martin Evans Fri May 12, 2023 05:31 AM

    Hi,

    As you are committing after the receipt of a single message (assuming you are not intending to make use of transacted sessions and that the browse option is a mistake) - I would consider using the JMS API and doing something like,

    get the message, do whatever you need to do with it, and then use CLIENT_ACKNOWLEDGE

    see, https://www.ibm.com/docs/en/ibm-mq/9.3?topic=application-acknowledgment-modes-jms-sessions

    stackoverflow is a great place to ask this kind of question if you tag it with 'ibm-mq'

    see, https://stackoverflow.com/questions/tagged/ibm-mq

    ------------------------------
    Regards,

    Martin Evans
    IBM MQ Technical Product Manager
    ------------------------------