如何在IBM MQ中重置队列? [英] How to reset a queue in IBM MQ?

查看:748
本文介绍了如何在IBM MQ中重置队列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何重置队列?在开始将消息写入队列之前,我想清除队列中的所有消息.我有什么方法可以不拨打电话而重设?

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);

MQMessage对象中有一个.clearmessages对象,但是我只能在调用get方法时访问它,我正在寻找一种方法来清除队列中的现有消息,然后再将新消息放入队列中.

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.

推荐答案

仅可以通过Get调用以编程方式清除队列中的消息.没有别的办法了.另外,您可以使用管理控制台清除消息,但这不是您要查找的内容.

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()丢弃消息缓冲区中的所有数据,并将数据偏移量重新设置为零.它不会清除队列中所有的消息.

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?

这篇关于如何在IBM MQ中重置队列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆