I am creating a messaging system using MQSeries. For some reason, when I execute q.get (...), I get an exception (I don't know the specific MQException). The following is the code that causes the error:
private static MQGetMessageOptions GMO = new MQGetMessageOptions(); private static int GMO_OPTIONS = MQC.MQGMO_SYNCPOINT | MQC.MQGMO_WAIT; GMO.options = GMO.options | GMO_OPTIONS; GMO.waitInterval = MQC.MQWI_UNLIMITED; MQEnvironment.hostname = args[0]; MQEnvironment.channel = args[2]; MQEnvironment.port = Integer.parseInt(args[1]); MQQueueManager queueManager = new MQQueueManager(args[3]) MQMessage msg = new MQMessage(); MQQueue q = queueManager.accessQueue("qName1",MQC.MQOO_OUTPUT); q.get(msg, GMO);
My plan is that if this error occurs, skip the message and delete it. To perform the uninstall, I will call the following function:
private void deleteMsg(MQQueueManager queueManager, String queueName) throws MQException { MQGetMessageOptions tempGmo = new MQGetMessageOptions(); tempGmo.options |= MQC.MQGMO_WAIT; tempGmo.waitInterval = 1000; MQQueue remover = queueManager.accessQueue(queueName, MQC.MQOO_INPUT_AS_Q_DEF); remover.get(new MQMessage(), tempGmo); queueManager.commit(); }
Will the remover.get () function in my deleteMsg function also in this particular scenario not for the same reason? Or does the parameter used to build the MQQueue (MQC.MQOO_INPUT_AS_Q_DEF vs MQC.MQOO_OUTPUT) also prevent it from crashing? If I have problems accessing my queue message, how do I delete the top message and move on to the next?
To shorten my question: If I cannot get () in the given queue to receive a message, how can we delete this damaged message in one queue?
Thanks!
source share