Author |
Message
|
_Angus_ |
Posted: Tue Oct 10, 2006 3:49 am Post subject: Channels remaining open on Queue Manager |
|
|
 Acolyte
Joined: 25 Apr 2005 Posts: 54 Location: Edinburgh
|
Hi there,
A team I'm helping have a problem where channels remain open on the Queue Manager after they have (seemingly) been closed properly by the client.
I don't know enough about JMS to spot this one but know something isn't tidying up properly. We are using MQ 5.3 CSD11 and the offending code is as follows:
----------------------------------------------------------------
private String sendMessage(String message, String jmsType) throws NamingException, JMSException
{
log.info("Encrypted Request: " + removeRestrictedLoggingElements(message));
//log.info("Request: " + message);
if(message.indexOf("<name>validateAndPriceOrder") != -1) {
log.debug("validateAndPriceOrder message.");
validateAndPriceOrderMessage = true;
}
InitialContext ic = new InitialContext();
QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory)ic.lookup(ApiConstants.QUEUE_FACTORY);
Queue queue = (Queue)ic.lookup(ApiConstants.SEND_QUEUE);
Queue receiveQueue = (Queue)ic.lookup(ApiConstants.RECEIVE_QUEUE);
QueueConnection connection = queueConnectionFactory.createQueueConnection();
try
{
connection.start();
//Create a queue session
QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
try{
//Send the message
QueueSender sender = session.createSender(queue);
try
{
TextMessage textMessage = session.createTextMessage(message);
// Default: Set the priority of message to 5
textMessage.setJMSPriority(5);
// Set the reply to queue
textMessage.setJMSReplyTo(receiveQueue);
// Set the domain to 'xml' and the type to jmsType
textMessage.setJMSType("mcd://xml//" + jmsType);
// Set a usr property
textMessage.setStringProperty("ErrorCode", "00000000");
//Send the message
sender.send(textMessage);
//Get the message id, this is used to filter the
//subsequent read of the reply to queue
String messageId = textMessage.getJMSMessageID();
return messageId;
}finally{
sender.close();
}
}finally{
session.close();
}
}
finally
{
connection.close();
}
}
---------------------------------------------------
Any help or pointers would be appreciated!
Angus _________________ *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Angus Cooke ~ AngusSoft
Integration Development Tools
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Oct 10, 2006 4:52 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Are you running in an App Server? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
_Angus_ |
Posted: Tue Oct 10, 2006 5:22 am Post subject: |
|
|
 Acolyte
Joined: 25 Apr 2005 Posts: 54 Location: Edinburgh
|
Yes, it is ... _________________ *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Angus Cooke ~ AngusSoft
Integration Development Tools
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Oct 10, 2006 6:31 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Then your app server is going to establish connections when it starts up, and hold those open as long as the app server runs.
That's it's job, to manage these connections for your application, and to prevent your application from having to wait for the connection to be established and then wait for the connection to be closed. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
_Angus_ |
Posted: Tue Oct 10, 2006 7:03 am Post subject: |
|
|
 Acolyte
Joined: 25 Apr 2005 Posts: 54 Location: Edinburgh
|
I understand that. But what we see is that, under load, new channels are spawned on the Queue Manager until it runs out of resource (ie. can't open any more channels!). _________________ *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Angus Cooke ~ AngusSoft
Integration Development Tools
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Oct 10, 2006 2:33 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
_Angus_ wrote: |
I understand that. But what we see is that, under load, new channels are spawned on the Queue Manager until it runs out of resource (ie. can't open any more channels!). |
That would be because your application is not well behaved and does not always close/release correctly the resources ?
In each of your finally blocks I would have put something like
Code: |
finally{
try{
object.close();
}catch (JMSException jmse){
//handle the exception
} finally {
object = null;
}//end finally (internal)
}//end finally external../ |
Enjoy
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
|