1
votes

How do i reset a queue? I want to clear all the messages in the queue, before i start to write a message into a queue. Is there any way i can reset without doing a get call?

MQQueueManager mqQMgr = new MQQueueManager(mqQueueManager);
MQQueue queue = mqQMgr.AccessQueue(getMessageQueue, MQC.MQOO_OUTPUT | MQC.MQOO_INPUT_SHARED | MQC.MQOO_INQUIRE);

There is a .clearmessages in MQMessage object, but i can access that only when i call a get method, i am looking for a way to clear the existing messages in the queue, before i can put a new message into the queue.

4

4 Answers

3
votes

Messages in a queue can be programatically cleared only with Get calls. There is no other way. Alternatively you use the administrative console to clear messages but that's not what you are looking for.

MQMessage.ClearMessage() discards any data in the message buffer and sets the data offset back to zero. It does not clear all the messages residing in a queue.

May I ask you why you want to clear the queue before putting new messages? What problem are you trying to solve?

1
votes

For clearing messages from a queue you can use the 'Clear Queue' PCF command. As I know, it clears queue faster than GET call, but you can use it only on closed queues. You can read about it in IBM MQ Infocenter: http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzac.doc/pc11350_.htm

0
votes

I have a couple of programs that you can use:

0
votes

Maybe this will help!

 private Color[] FloodTest(Color[] color, TouchLocation touch, Texture2D tex)
    {

        Queue<Point> q = new Queue<Point>();
        q.Enqueue(pt);
        while (q.Count > 0)
        {
            if (q.Count > 800000) break; 
        }

        q.Clear();
        q = null;
        return color;
    }

I removed not important code. Please look at q.Count.