| Author | Message | 
		
		  | pavan-mq | 
			  
				|  Posted: Tue Apr 06, 2010 4:32 am    Post subject: Max channels when MQ Command server is down |   |  | 
		
		  | Novice
 
 
 Joined: 03 Feb 2010Posts: 13
 
 
 | 
			  
				| Hi Everyone, 
 i am new to Mq and i am using PCFMessage Agent to connect to the MQ and every thing is working fine for me untill this has happened.
 
 if i try to connect to the MQ using pcfmessage agent when MQCommand server is down, it fails (not a problem), but it appears that the server connection channel is not terminated.
 
 In turn, the connection will hang around and when i make subsequent attempts to connect at regular interval, the previous connection won't give up, eventually, the MQ server will hit the MAX CHANNELS configured to it then NO channels will be able to connect at all.
 
 i checked the code and i am calling the disconnect() properly. Is there anything i am missing
  . Thanks in Advance. |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Tue Apr 06, 2010 5:16 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| What you're missing is the guidance to new posters which explains it's considered rude to double post! 
 I've locked this version of your question.
 
 
      _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | pavan-mq | 
			  
				|  Posted: Tue Apr 06, 2010 6:55 am    Post subject: |   |  | 
		
		  | Novice
 
 
 Joined: 03 Feb 2010Posts: 13
 
 
 | 
			  
				| i thought i had posted the first one in different forum "websphere mq api support" that's why i posted again in correct one "general websphere mq support"  Sorry for that. |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Tue Apr 06, 2010 7:25 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| As it says in the guidance, if you post in the wrong forum just ask a moderator to move it. _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mvic | 
			  
				|  Posted: Tue Apr 06, 2010 9:26 am    Post subject: Re: Max channels when MQ Command server is down |   |  | 
		
		  |  Jedi
 
 
 Joined: 09 Mar 2004Posts: 2080
 
 
 | 
			  
				| Can you use DIS CHS and DIS CONN to find out whether the channels for your program really are the ones leaking..  If they are, you may need to find out why your disconnect() call is apparently not disconnecting. |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Tue Apr 06, 2010 8:06 pm    Post subject: Re: Max channels when MQ Command server is down |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| 
   
	| mvic wrote: |  
	| Can you use DIS CHS and DIS CONN to find out whether the channels for your program really are the ones leaking..  If they are, you may need to find out why your disconnect() call is apparently not disconnecting. |  
 Are you sure your disconnect call is  rightly placed? What happens in case an exception is thrown. Do you still disconnect (try, catch , finally)?
 
 Have fun
  _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | pavan-mq | 
			  
				|  Posted: Wed Apr 07, 2010 12:15 am    Post subject: |   |  | 
		
		  | Novice
 
 
 Joined: 03 Feb 2010Posts: 13
 
 
 | 
			  
				| Thanks for replies guys, 
 I have placed the disconnect() in finally block only. For reference i am posting my code here.
 
 
 
   
	| Code: |  
	| 
 import java.io.*;
 import java.util.*;
 import com.ibm.mq.*;
 import com.ibm.mq.pcf.*;
 
 public class MQTest
 {
 public  void main (String [] args)
 {
 String host="host";
 String port="1414";
 String channel="server_channel";
 
 if(args.length>0){
 host=args [0];
 port=args [1];
 channel=args [2];
 }
 System.out.print ("Connecting to queue manager at " + host + ":" + port + " over channel " + channel );
 
 PCFMessageAgent   agent=null;
 try{
 agent = new PCFMessageAgent (host, Integer.parseInt (port), channel);
 getData(agent);
 }
 catch (ArrayIndexOutOfBoundsException abe){
 System.out.println ("Usage:\t java MQTest host port channel");
 }
 catch (PCFException pcfe){
 System.err.println ("Error in response: ");
 PCFMessage []    responses = (PCFMessage []) pcfe.exceptionSource;
 for (int i = 0; i < responses.length; i++){
 System.out.println (responses [i]);
 }
 }
 catch (MQException mqe){
 mqe.printStackTrace();
 System.out.println("Reason code   "+mqe.reasonCode);
 System.out.println("Exception is %%%%% :"+PCFConstants.lookupReasonCode (mqe.reasonCode));
 }
 catch(Exception ex){
 ex.printStackTrace();
 }
 finally{
 try{
 if(agent!=null)
 agent.disconnect();
 }
 catch(Exception ex){}
 }
 
 }
 
 
 public   void getData(PCFMessageAgent agent)
 {
 StringBuffer output=new StringBuffer();
 try{
 System.out.println("====== Output ======= \n");
 getQueueStats(agent);
 }
 catch(Exception ex){
 ex.printStackTrace();
 }
 }
 
 
 public   void getQueueStats(PCFMessageAgent agent)
 {
 StringBuffer queueOutput=new StringBuffer();
 
 try{
 PCFMessage    request;
 PCFMessage []    responses;
 request = new PCFMessage (CMQCFC.MQCMD_INQUIRE_Q);
 request.addParameter (CMQC.MQCA_Q_NAME, "*");
 request.addParameter (CMQC.MQIA_Q_TYPE, CMQC.MQQT_LOCAL);
 request.addParameter (CMQCFC.MQIACF_Q_ATTRS,
 new int [] {
 CMQC.MQCA_Q_NAME,CMQC.MQIA_CURRENT_Q_DEPTH,
 CMQC.MQIA_OPEN_INPUT_COUNT,
 CMQC.MQIA_OPEN_OUTPUT_COUNT,
 CMQC.MQIA_DEFINITION_TYPE});
 
 responses = agent.send (request);
 
 queueOutput.append("Queue Name \t | Current Depth \t | % of Queue Occupied \t | Open Input Count \t | Open Output Count");
 queueOutput.append("\n");
 
 for (int i = 0; i < responses.length; i++)
 {
 String       name = responses [i].getStringParameterValue (CMQC.MQCA_Q_NAME);
 int       depth = responses [i].getIntParameterValue (CMQC.MQIA_CURRENT_Q_DEPTH);
 int         inputCount=responses [i].getIntParameterValue (CMQC.MQIA_OPEN_INPUT_COUNT);
 int         outputCount=responses [i].getIntParameterValue (CMQC.MQIA_OPEN_OUTPUT_COUNT);
 int         maxdepth=responses [i].getIntParameterValue (CMQC.MQIA_MAX_Q_DEPTH);
 //% Queue Depth occupied of Max Queue Depth
 int         percentQueueOcccupied=(depth*100)/maxdepth;
 
 
 //int         qtype=responses [i].getIntParameterValue (CMQC.MQIA_Q_TYPE);
 // MQIA_DEFINITION_TYPE was 3 for temporary queues and 1 for all other queues
 // This was found out by listing attributes of the queue and check.
 // need to find out how to filter System Queues also.
 int         def_type=responses [i].getIntParameterValue (CMQC.MQIA_DEFINITION_TYPE);
 
 if(def_type!=1)
 continue;
 
 queueOutput.append(name +"\t |"+ depth +"\t |"+ percentQueueOcccupied +"\t |"+ inputCount +"\t |"+ outputCount);
 queueOutput.append("\n");
 }
 }
 
 catch (PCFException pcfe){
 System.err.println ("Error in response: ");
 PCFMessage []    responses = (PCFMessage []) pcfe.exceptionSource;
 
 for (int i = 0; i < responses.length; i++){
 System.out.println (responses [i]);
 }
 }
 catch (MQException mqe){
 mqe.printStackTrace();
 System.out.println("TEST222  "+mqe.reasonCode);
 System.err.println (mqe);
 }
 catch (IOException ioe){
 ioe.printStackTrace();
 }
 catch(Exception ex){
 ex.printStackTrace();
 }
 
 System.out.println(queueOutput.toString());
 }
 
 
 }
 
 |  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Wed Apr 07, 2010 5:24 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| Have you given any thought to running your app with a coverage trace while forcing the issue ( cmd srvr down)  _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | pavan-mq | 
			  
				|  Posted: Fri Apr 09, 2010 4:22 am    Post subject: |   |  | 
		
		  | Novice
 
 
 Joined: 03 Feb 2010Posts: 13
 
 
 | 
			  
				| I enabled the trace, but its hard to find any information from those traces for newbie's like me  . i looked into the queue's error logs which says that 
 
   
	| Quote: |  
	| Channel program 'channel_1' ended abnormally.  There are too many channels active to start another. |  
 while getting the trace by forcing the issue i found that the connections created by the application when command server is down is not giving up even after starting the command server.
 
 Checking the applications connected to the QueueManager, i found the connections made from application when cmd server is down are in suspended state.
  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Fri Apr 09, 2010 11:57 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| Well the coverage trace would tell you exactly if you execute the disconnect from the qmgr when the command server is down...  _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |