Connect to MQQueue from JSF
Hi,
I would like to get the count of messages in a MQ queue from my JSF program. I have a working Java program that works fine but not sure how I should implement it with JSF. Can you please suggest? I am enclosing the Java program here for your reference:
This program loops thru two queues and gets the count of messages in two queues. Also, this program runs directly on the server where the MQ is located.
Thanks
Aish
package com.test;
import java.io.*;
import com.ibm.mq.*;
public class GetMessage implements Runnable {
private static String[] iQueues = new String[2];
private static String iQmgr = null;
private static int[] depth = new int[2];
public GetMessage()
{
iQmgr = "Name";
iQueues[0] = new String("Input1");
iQueues[1] = new String("Input2");
}
public GetMessage(String[] args)
{
this();
}
public void run() {
MQQueueManager qMgr;
System.out.println("GetMessage started....");
MQException.log = null;
try {
if (iQmgr != null) {
qMgr = new MQQueueManager(iQmgr);
} else {
qMgr = new MQQueueManager("");
}
try {
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_INQUIRE | MQC.MQOO_FAIL_IF_QUIESCING;
for (int i=0; i < iQueues.length ; i++ )
{
String iQueue = iQueues;
System.out.println(iQueue);
MQQueue myQueue = qMgr.accessQueue(iQueue, openOptions, null, null, null);
depth[i] = myQueue.getCurrentDepth();
myQueue.close();
}
}
catch (MQException ex) {
System.err.println(
"Error opening queue "
+ ex.completionCode
+ " "
+ ex.reasonCode);
}
qMgr.disconnect();
} catch (MQException ex) {
System.err.println(
"Error opening queue manager "
+ ex.completionCode
+ " "
+ ex.reasonCode);
}
for (int i=0; i < iQueues.length ; i++ )
{
System.out.println("No of messages in " + iQueues[i] +" is "+depth[i]);
}
System.out.println("GetMessage finished....");
}
public static void main(String[] args) {
GetMessage app = new GetMessage(args);
Thread t = new Thread(app);
t.start();
}
}
}