| Author | Message | 
		
		  | kendras | 
			  
				|  Posted: Fri Oct 13, 2006 1:27 am    Post subject: MQRC_HCONN_ERROR |   |  | 
		
		  | Novice
 
 
 Joined: 31 Jan 2006Posts: 12
 
 
 | 
			  
				| I've made a windows service called DuplicationWMQ. This service take a message in a file, and put it in others file.
 It's work in cluster and my WMQ Server too.
 
 When the WMQ server pass on the other node of the cluster, my application lost the connection, and can't open it again.
 
 This is my error :
 
 
 
   
	| Code: |  
	| Type de l'événement :   Erreur Source de l'événement :   DuplicationWmq
 Catégorie de l'événement :   Aucun
 ID de l'événement :   0
 Date :      28/09/2006
 Heure :      11:23:48
 Utilisateur :   N/A
 Ordinateur :   *********
 Description :
 La description pour l'ID d'événement ( 0 ) dans la source (DuplicationWmq) est introuvable. L'ordinateur local n'a peut-être pas les informations de Registre ou les librairies requises pour afficher les messages émanant d'un ordinateur distant. Vous pourrez peut-être utiliser l'option /AUXSOURCE= pour récupérer cette description. Reportez-vous aux rubriques Aide et support pour plus de détails. Les informations suivantes font partie de l'événement : MQRC_HCONN_ERROR [   at IBM.WMQ.MQQueue..ctor(MQQueueManager qMgr, String queueName, Int32 openOptions, String queueManagerName, String dynamicQueueName, String alternateUserId)
 at IBM.WMQ.MQQueueManager.AccessQueue(String queueName, Int32 openOptions, String queueManagerName, String dynamicQueueName, String alternateUserId)
 at IBM.WMQ.MQQueueManager.AccessQueue(String queueName, Int32 openOptions)
 at DuplicationWmq.WmqComponent.ExternalDupliq(ArrayList extQueues, MQMessage MessageIN)].
 
 |  
 This is my code source :
 
 
 
   
	| Code: |  
	| private void ExternalDupliq(ArrayList extQueues, MQMessage MessageIN, string logFileName, string inQueueName) {
 MQPutMessageOptions pmo = new MQPutMessageOptions();
 
 foreach(ExternalQueue extQueue in extQueues)
 {
 MQQueueManager extQMgr = null;
 MQQueue myExtQueue = null;
 try
 {
 MQEnvironment.Port     = extQueue.Port;
 MQEnvironment.Channel  = extQueue.Canal;
 MQEnvironment.Hostname = extQueue.Machine;
 extQMgr = new MQQueueManager(extQueue.ManagerName);
 myExtQueue = extQMgr.AccessQueue(extQueue.QueueName, openOutOptions);
 myExtQueue.Put(MessageIN, pmo);
 }
 catch(Exception ex)
 {
 string message = "InQueue Name : " + inQueueName
 + "\nOutQueue Name : " + extQueue.QueueName
 + "\nType Erreur : External Dupliq"
 + "\nMessage d'erreur : " + ex.Message
 + "\nStackTrace : " + ex.StackTrace;
 
 Common.WriteThreadXml(logFileName,inQueueName, message ,1);
 Log.Error(message);
 goto EXIT;
 }
 
 EXIT:
 try
 {
 if ((myExtQueue != null) && myExtQueue.IsOpen)
 myExtQueue.Close();
 CloseMQ(ref extQMgr);
 
 }
 catch(Exception ex)
 {
 string message = "Queue Name : " + inQueueName
 + "\nType Erreur : External Dupliq [CLEAR]"
 + "\nMessage d'erreur : " + ex.Message
 + "\nStackTrace : " + ex.StackTrace;
 
 Common.WriteThreadXml(logFileName,inQueueName, message ,1);
 Log.Error(message);
 }
 }
 
 return;
 
 }
 
 |  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | jefflowrey | 
			  
				|  Posted: Fri Oct 13, 2006 1:29 am    Post subject: |   |  | 
		
		  | Grand Poobah
 
 
 Joined: 16 Oct 2002Posts: 19981
 
 
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kendras | 
			  
				|  Posted: Fri Oct 13, 2006 2:20 am    Post subject: |   |  | 
		
		  | Novice
 
 
 Joined: 31 Jan 2006Posts: 12
 
 
 | 
			  
				| i've already read this, and there no answer for me... |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Fri Oct 13, 2006 2:34 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| 
   
	| Quote: |  
	| 2018 (X'07E2')MQRC_HCONN_ERROR Explanation:
 The connection handle Hconn is not valid, for one of the following reasons:
 
 The parameter pointer is not valid, or (for the MQCONN or MQCONNX call) points to read-only storage. (It is not always possible to detect parameter pointers that are not valid; if not detected, unpredictable results occur.)
 The value specified was not returned by a preceding MQCONN or MQCONNX call.
 The value specified has been made invalid by a preceding MQDISC call.
 The handle is a shared handle that has been made invalid by another thread issuing the MQDISC call.
 The handle is a shared handle that is being used on the MQBEGIN call (only nonshared handles are valid on MQBEGIN).
 The handle is a nonshared handle that is being used a thread that did not create the handle.
 The call was issued in the MTS environment in a situation where the handle is not valid (for example, passing the handle between processes or packages; note that passing the handle between library packages is supported).
 Completion Code:
 MQCC_FAILED
 
 Programmer Response:
 Ensure that a successful MQCONN or MQCONNX call is performed for the queue manager, and that an MQDISC call has not already been performed for it. Ensure that the handle is being used within its valid scope (see the description of MQCONN in the WebSphere MQ Application Programming Guide).
 
 |  
 
 
   
	| kendras wrote: |  
	| When the WMQ server pass on the other node of the cluster, my application lost the connection, and can't open it again. |  
 Do you mean the other node of a failover cluster? If so, are you sure the connection object is properly recreated (the old one won't work).
 _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kendras | 
			  
				|  Posted: Fri Oct 13, 2006 2:43 am    Post subject: |   |  | 
		
		  | Novice
 
 
 Joined: 31 Jan 2006Posts: 12
 
 
 | 
			  
				| yes, the over node of a failover cluster. 
 On an exception, i close properly my connection (with the method CloseMQ), to recreate it.
 
 
   
	| Code: |  
	| private void CloseMQ(ref MQQueueManager mqQMgr)
 {
 if(mqQMgr.IsConnected==true || mqQMgr!=null)
 {
 mqQMgr.Disconnect();
 mqQMgr = null;
 }
 }
 |  
 It seems to have a thing like a cache, and it can't open a new connection...
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Fri Oct 13, 2006 2:51 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| Ok, my Java is very, very weak so please bear that in mind. 
 The error that MQ is throwing is when the program presents a connection object that is no longer valid. This (I think but see above) is in the MQEnvironment object where the port & the channel are set. I don't see where that's being reset in your code. Are you sure all the objects are properly rebuilt on failover? What happens it, when you catch this error, you drop and recreate the connection via MQEnvironment?
 _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Fri Oct 13, 2006 2:59 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| You really need to get more out of the exception handling and more specifically the reason code. 
 This is the only indicator that will tell you what is wrong with the connection attempt.
 
 Remember as well that the environment variable MQEnvironment is a singleton and may affect your current connection. Use the hashtable to create multiple connections in the same CLR/JVM.
 
 Enjoy
  _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kendras | 
			  
				|  Posted: Fri Oct 13, 2006 3:16 am    Post subject: |   |  | 
		
		  | Novice
 
 
 Joined: 31 Jan 2006Posts: 12
 
 
 | 
			  
				| Ok, I'll use the MQException to get more information about my error. 
 Thanks for the help
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | jefflowrey | 
			  
				|  Posted: Fri Oct 13, 2006 3:20 am    Post subject: |   |  | 
		
		  | Grand Poobah
 
 
 Joined: 16 Oct 2002Posts: 19981
 
 
 | 
			  
				| This is C#, not Java. 
 AccessQueue is a giveaway.  In Java it would be "accessQueue".
 
 The same with "string" vs "String".  And "IBM.WMQ." and not "com.ibm."
 
 Plus, Java applications don't usually get 2018s.  Particularly not in threading situations.
 
 Also, as a suggestion, you probably want to reorganize the OR clause in your CloseMQ, to ensure that you don't try and run IsConnected on a null object.
 _________________
 I am *not* the model of the modern major general.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Fri Oct 13, 2006 3:24 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| 
   
	| jefflowrey wrote: |  
	| This is C#, not Java. |  
 My level of C# knowledge is eloquently displayed by the fact I couldn't tell the difference...
  _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kendras | 
			  
				|  Posted: Mon Oct 16, 2006 4:49 am    Post subject: |   |  | 
		
		  | Novice
 
 
 Joined: 31 Jan 2006Posts: 12
 
 
 | 
			  
				| So..... 
 I've tried to get more informations  about my WMQ error..
 
 And this is what I get :
 
 CompletionCode : 2
 ReasonCode : 2018
 
 How can I clean my connection to reconnect properly ?
 
 I got this :
 
 
 
   
	| Code: |  
	| private void ExternalDupliq(ArrayList extQueues, MQMessage MessageIN, string logFileName, string inQueueName) {
 MQPutMessageOptions pmo = new MQPutMessageOptions();
 
 foreach(ExternalQueue extQueue in extQueues)
 {
 MQQueueManager extQMgr = null;
 MQQueue myExtQueue = null;
 try
 {
 MQEnvironment.Port     = extQueue.Port;
 MQEnvironment.Channel  = extQueue.Canal;
 MQEnvironment.Hostname = extQueue.Machine;
 extQMgr = new MQQueueManager(extQueue.ManagerName);
 myExtQueue = extQMgr.AccessQueue(extQueue.QueueName, openOutOptions);
 myExtQueue.Put(MessageIN, pmo);
 }
 catch (MQException ex)
 {
 string message = "InQueue Name : " + inQueueName
 + "\nOutQueue Name : " + extQueue.QueueName
 + "\nType Erreur : External Dupliq"
 + "\nCompletionCode : " + ex.CompletionCode
 + "\nReasonCode : " + ex.ReasonCode;
 
 Common.WriteThreadXml(logFileName,inQueueName, message ,1);
 Log.Error(message);
 goto EXIT;
 }
 
 catch(Exception ex)
 {
 string message = "InQueue Name : " + inQueueName
 + "\nOutQueue Name : " + extQueue.QueueName
 + "\nType Erreur : External Dupliq"
 + "\nMessage d'erreur : " + ex.Message
 + "\nStackTrace : " + ex.StackTrace;
 
 Common.WriteThreadXml(logFileName,inQueueName, message ,1);
 Log.Error(message);
 goto EXIT;
 }
 
 EXIT:
 try
 {
 if ((myExtQueue != null) && myExtQueue.IsOpen)
 myExtQueue.Close();
 CloseMQ(ref extQMgr);
 
 }
 catch(Exception ex)
 {
 string message = "Queue Name : " + inQueueName
 + "\nType Erreur : External Dupliq [CLEAR]"
 + "\nMessage d'erreur : " + ex.Message
 + "\nStackTrace : " + ex.StackTrace;
 
 Common.WriteThreadXml(logFileName,inQueueName, message ,1);
 Log.Error(message);
 }
 MQEnvironment.Channel  = null;
 MQEnvironment.Hostname = null;
 }
 
 return;
 
 }
 |  
 
 
 
   
	| Code: |  
	| private void CloseMQ(ref MQQueueManager mqQMgr) {
 if(mqQMgr.IsConnected==true || mqQMgr!=null)
 {
 mqQMgr.Disconnect();
 mqQMgr = null;
 }
 }
 |  
 Any suggestion ?
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Mon Oct 16, 2006 2:57 pm    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| Your exception handling is still dirty: 
 
   
	| Quote: |  
	| EXIT: try
 {
 if ((myExtQueue != null) && myExtQueue.IsOpen)
 myExtQueue.Close();
 CloseMQ(ref extQMgr);
 
 }
 catch(Exception ex)
 {
 string message = "Queue Name : " + inQueueName
 + "\nType Erreur : External Dupliq [CLEAR]"
 + "\nMessage d'erreur : " + ex.Message
 + "\nStackTrace : " + ex.StackTrace;
 
 Common.WriteThreadXml(logFileName,inQueueName, message ,1);
 Log.Error(message);
 }
 MQEnvironment.Channel  = null;
 MQEnvironment.Hostname = null;
 
 |  So now what happens if you have an exception on myExtQueue.Close(); ?
 What is the state of your connection variables?
 _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | jefflowrey | 
			  
				|  Posted: Mon Oct 16, 2006 3:38 pm    Post subject: |   |  | 
		
		  | Grand Poobah
 
 
 Joined: 16 Oct 2002Posts: 19981
 
 
 | 
			  
				| What happens if an exception occurs at new MQQueueManager? _________________
 I am *not* the model of the modern major general.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |