Every time you call the handleTask method, it creates a new qmgr object
and opens the queue (if my 30secs reading this is right it will be doing
an MQCONN and MQOPEN). Do you see the open input/output count on the
queue go up as this is used?
Why aren't you reusing the qmgr/queue objects?
Regards
John Scott
IBM Certified Specialist - MQSeries
Home Retail Group (Infrastructure Services - Middleware)
-----Original Message-----
From: MQSeries List [mailto:[EMAIL PROTECTED]
On Behalf Of Coombs, Lawrence
Sent: 13 November 2007 16:28
To: [email protected]
Subject: FW: MQ Java problem (jTail)...Help !!!!!!1
Environment :
QA AIX 5.2, MQ 5.3.6
Production - AIX 5.3, MQ 5.3.8
A java main program which parses an input file and reads through
all the records and follows the trail in a tail -f fashion.
It then gets a handle to this class and then passes the message
as a LogMessage to the method handleTaks below.
We're running the program under standard sun java installed on
this host
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1)
Classic VM (build 1.4.1, J2RE 1.4.1 IBM AIX build
ca1411-20040301 (JIT enabled: jitc))
Problem:
When I implemented this in production, we are spawning a lot of
amqzlaa0 processes. It even crashed the queue manager a couple of day
ago (MAXUPROC reached).
Does anyone see a problem with this code? The code is exactly
like what is documented in the MQ java manual.
************************************************************************
************************************************************************
**************************************************
package com.sears.esbmonitor.mq;
import java.io.IOException;
import com.ibm.mq.MQC;
import com.ibm.mq.MQEnvironment;
import com.ibm.mq.MQException;
import com.ibm.mq.MQMessage;
import com.ibm.mq.MQPoolToken;
import com.ibm.mq.MQPutMessageOptions;
import com.ibm.mq.MQQueue;
import com.ibm.mq.MQQueueManager;
import com.ibm.mq.MQSimpleConnectionManager;
import com.sears.esbmonitor.tailer.LogMessage;
/**
* @author KDRONAM
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and
Comments
*/
public class MQSender {
static String queueMgrName, queueName;
static int maxConn;
static MQQueueManager qMgr;
static MQSimpleConnectionManager myConnMan;
static MQSender instance = null;
public static MQPoolToken token;
public static MQSender getInstance() {
if (instance == null) {
instance = new
MQSender();
try {
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,
MQC.TRANSPORT_MQSERIES_BINDINGS);
myConnMan=new MQSimpleConnectionManager();
myConnMan.setActive(MQSimpleConnectionManager.MODE_AUTO);
myConnMan.setTimeout(3600000);
myConnMan.setMaxUnusedConnections(50);
MQEnvironment.setDefaultConnectionManager(myConnMan);
token=MQEnvironment.addConnectionPoolToken();
} catch
(NullPointerException e) {
e.printStackTrace(); // problem retrieving parameters
} catch
(NumberFormatException e) {
e.printStackTrace(); // problem retrieving parameters
} catch
(Throwable e) { // unknown problem
e.printStackTrace();
}
}
return instance;
}
public void handleTask(LogMessage logMsg) throws
Throwable {
try {
qMgr = new
MQQueueManager(queueMgrName, myConnMan);
int openOptions =
MQC.MQOO_OUTPUT ; // output only
MQQueue queue =
qMgr.accessQueue(queueName, openOptions, null, null, null);
MQMessage mqMsg = new
MQMessage();
mqMsg.expiry =
MQC.MQEI_UNLIMITED;
mqMsg.format =
MQC.MQFMT_STRING;
logMsg.write(mqMsg);
MQPutMessageOptions pmo =
new MQPutMessageOptions();
queue.put(mqMsg, pmo);
queue.close();
qMgr.disconnect();
} catch (IOException e) {
System.err.println(this + "
IO Exception" + e.getMessage());
throw e;
} catch (MQException e) {
System.err.println(this + "
MQException " + e.getMessage());
throw e;
} catch (Exception e) {
throw e;
}
}
public void destroy() {
MQEnvironment.removeConnectionPoolToken(token);
}
/**
* @param string
*/
public static void setQueueMgrName(String QMgr) {
queueMgrName = QMgr;
}
/**
* @param string
*/
public static void setQueueName(String queue) {
queueName = queue;
}
public static void setMaxConn(int max) {
maxConn = max;
}
}
________________________________
List Archive
<http://listserv.meduniwien.ac.at/archives/mqser-l.html> - Manage Your
List Settings
<http://listserv.meduniwien.ac.at/cgi-bin/wa?SUBED1=mqser-l&A=1> -
Unsubscribe
<mailto:[EMAIL PROTECTED]&BODY=sign
off%20mqseries>
Instructions for managing your mailing list subscription are
provided in the Listserv General Users Guide available at
http://www.lsoft.com <http://www.lsoft.com/resources/manuals.asp>
The information contained in this message or any of its attachments is
confidential and may be privileged.
Unauthorised disclosure, copying or dissemination of the contents is strictly
prohibited.
The views expressed may not be official policy, but the personal views of the
originator.
If you are not the intended recipient or have received this message in error,
please delete this e-mail and advise the sender by using the reply facility in
your e-mail software.
All messages sent and received by Home Retail Group are monitored for viruses,
high-risk file extensions, and inappropriate content.
The registered office address of Home Retail Group plc (registered in London,
number 5863533) is
Avebury,
489-499 Avebury Boulevard,
Milton Keynes
MK9 2NW.
Please visit our website at http://www.HomeRetailGroup.com for further
information about Home Retail Group.
To unsubscribe, write to [EMAIL PROTECTED] and,
in the message body (not the subject), write: SIGNOFF MQSERIES
Instructions for managing your mailing list subscription are provided in
the Listserv General Users Guide available at http://www.lsoft.com
Archive: http://listserv.meduniwien.ac.at/archives/mqser-l.html