Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Connect to MQQueue from JSF

843844Apr 1 2008
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();
}
}

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 29 2008
Added on Apr 1 2008
0 comments
151 views