IBM MQ Queue Monitor
来源:互联网 发布:网络检测插件 编辑:程序博客网 时间:2024/05/21 19:25
Queue的访问方式有多种:
MQOO_BROWSE:浏览,可获取其中的message,但是获取后,原有message依然存在
MQOO_INQUIRE:可以调用getCurrentDepth();其他状态会跑出异常
package com.iss.ibm.monitor;
import java.io.IOException;
import java.util.Date;
import com.ibm.mq.MQC;
import com.ibm.mq.MQException;
import com.ibm.mq.MQGetMessageOptions;
import com.ibm.mq.MQMessage;
import com.ibm.mq.MQQueue;
import com.ibm.mq.MQQueueManager;
import com.iss.ibm.monitor.model.QueueMonitorTotleModel;
public class QueueMonitor
{
private String qName;
private MQQueueManager queueManager;
public QueueMonitor(String qName, MQQueueManager queueManager)
{
this.qName = qName;
this.queueManager = queueManager;
}
/**
* 获取浏览状态的queue
* @author 王成(chengwangi@isoftstone.com)
* @date 2012-11-16 上午10:20:11
* @return
* @throws MQException
*/
@SuppressWarnings("deprecation")
public MQQueue getBrowseQueueForQName() throws MQException
{
MQQueue browseQueue = null;
MQException.log = null; /* don't print out any exceptions */
int openOptions = MQC.MQOO_BROWSE;
browseQueue = queueManager.accessQueue(qName, openOptions, null, null, null);
return browseQueue;
}
/**
* 获取浏览状态的queue
* @author 王成(chengwangi@isoftstone.com)
* @date 2012-11-16 上午10:20:11
* @return
* @throws MQException
*/
@SuppressWarnings("deprecation")
public int getQueueDepthForQName() throws MQException
{
MQQueue browseQueue = null;
MQException.log = null; /* don't print out any exceptions */
int openOptions = MQC.MQOO_INQUIRE;
browseQueue = queueManager.accessQueue(qName, openOptions, null, null, null);
try {
return browseQueue.getCurrentDepth();
} catch (MQException e1) {
// e1.printStackTrace();
}
return 0;
}
/**
* 获取queue的监控信息
* @author 王成(chengwangi@isoftstone.com)
* @date 2012-11-16 上午10:25:13
* @param queue
* @return
* @throws IOException
*/
@SuppressWarnings("deprecation")
public QueueMonitorTotleModel getQueueMonitorTotleMondel(MQQueue queue) throws IOException
{
QueueMonitorTotleModel totle = new QueueMonitorTotleModel();
totle.setQueueName(queue.name);
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = gmo.options + MQC.MQGMO_BROWSE_NEXT;
MQMessage myMessage = new MQMessage();
int msgCount = 0;
long date = 0l;
while(true)
{
myMessage.clearMessage();
myMessage.correlationId = MQC.MQCI_NONE;
myMessage.messageId = MQC.MQMI_NONE;
try
{
queue.get(myMessage, gmo);
long currentDate = myMessage.putDateTime.getTimeInMillis();
if(date == 0 || currentDate <= date)
date = currentDate;
} catch (MQException e)
{
break;
}
msgCount ++;
}
totle.setMsgCount(msgCount);
totle.setEarliestMsgDate(new Date(date));
return totle;
}
/**
* 获取queue的监控信息
* @author 王成(chengwangi@isoftstone.com)
* @date 2012-11-16 上午10:25:13
* @param queue
* @return
* @throws IOException
*/
@SuppressWarnings("deprecation")
public QueueMonitorTotleModel getQueueMonitorTotleMondelForEarliestQueue(MQQueue queue) throws IOException
{
QueueMonitorTotleModel totle = new QueueMonitorTotleModel();
totle.setQueueName(queue.name);
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = gmo.options + MQC.MQGMO_BROWSE_NEXT;
MQMessage myMessage = new MQMessage();
int msgCount = 0;
long date = 0l;
myMessage.clearMessage();
myMessage.correlationId = MQC.MQCI_NONE;
myMessage.messageId = MQC.MQMI_NONE;
try
{
queue.get(myMessage, gmo);
long currentDate = myMessage.putDateTime.getTimeInMillis();
date = currentDate;
} catch (MQException e)
{}
totle.setMsgCount(msgCount);
totle.setEarliestMsgDate(new Date(date));
return totle;
}
}
- IBM MQ Queue Monitor
- IBM MQ Monitor
- 在IBM MQ的queue上设置trigger
- IBM MQ
- IBM Message Broker(IBM ESB产品)查询MQ(Message Queue)中已经创建了哪些队列
- Message Queue - MQ Intro
- IBM MQ 使用指南
- IBM MQ 介绍
- IBM MQ介绍
- IBM MQ 使用指南
- IBM MQ 使用指南
- IBM MB MQ简介
- IBM WebSphere MQ监控
- ibm MB MQ
- IBM Websphere MQ
- IBM WebSphere MQ安装
- IBM WebSphere MQ
- 初探IBM Websphase MQ
- icon各种尺寸
- 常见mime type
- MySQL服务器的启动与退出
- POJ 1521 哈夫曼树
- Spring Mail邮件发送
- IBM MQ Queue Monitor
- ecshop 订单状态改变后 前后台功能菜单的显示
- 调试小记2
- java中 实现无标题无边框的窗体能够用鼠标拖动改变窗口大小
- SAP发送邮件
- C# 浏览文件按钮选项 浏览文件所在路径
- jquery的ajax请求struts action返回json时XmlHttpRequest.status500错误
- OpenCV源码中Haar训练及提取特征的代码
- jsp乱码解决大全