| Author | Message | 
		
		  | vikasdottv | 
			  
				|  Posted: Thu Mar 04, 2010 10:07 am    Post subject: second app on same PC calling MQQueueManager.connect err2012 |   |  | 
		
		  | Newbie
 
 
 Joined: 04 Mar 2010Posts: 4
 
 
 | 
			  
				| Hi, 
 I have two applications consumer and generator.
 
 Consumer is written using C++.
 Generator is written using C#
 
 Both are not able to run at the same time at the point when they try to connect to same MQ Queue Manager. Whichever I run first, successfully connect to the MQ queue manager but second one gives error reason code 2012 and completion code 2. MQRC_ENVIRONMENT_ERROR
 
 Could you please advise? I am trying to run both from Windows XP PC.
 
 Please see my code below.
 
 Consumer C++ code
 ------------------------------
 channel_.setChannelName(addr_.getChannel().c_str());  //It will resolve to channel_.setChannelName("VINF01");
 channel_.setTransportType(MQXPT_TCP);
 
 std::stringstream connectionName;
 connectionName << addr_.getMachineName() << "(" << addr_.getPort() << ")" << std::ends;
 
 channel_.setConnectionName(connectionName.str().c_str()); // channel_.setConnectionName("vs256v1.cm.com(1005)");
 
 ImqQueueManager queueMgr;
 queueMgr_.setChannelReference(channel_);
 queueMgr_.setName(addr_.getQManager().c_str()); //queueMgr_.setName("DSLNDV04");
 queueMgr_.setConnectOptions(MQCNO_NONE);
 
 
 ImqBoolean retcode = queueMgr_.connect();
 if (!retcode)
 {
 std::stringstream errorStream;
 
 
 Generator C# code
 --------------------------------
 Hashtable queueProperties = new Hashtable();
 queueProperties[MQC.HOST_NAME_PROPERTY] = reqHostname_; //"vs256v1.cm.com"
 queueProperties[MQC.PORT_PROPERTY] = reqPort_; //1005
 queueProperties[MQC.CHANNEL_PROPERTY] = reqChannel_; //"VINF01"
 
 IBM.WMQ.MQQueueManager mqQMgrReq_;
 mqQMgrReq_ = new MQQueueManager(reqQueueManagerName_, queueProperties);
 //here reqQueueManagerName_="DSLNDV04"
 
 Thanks & Regards
 Vikas Agrawal
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Thu Mar 04, 2010 12:07 pm    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| The MQEnvironment is a singleton pattern in your CLR. 
 You need to use alternate constructors to the queue manager like properties and stuff.
 
 Have fun
  _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | vikasdottv | 
			  
				|  Posted: Thu Mar 04, 2010 2:31 pm    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 04 Mar 2010Posts: 4
 
 
 | 
			  
				| 
   
	| fjb_saper wrote: |  
	| The MQEnvironment is a singleton pattern in your CLR. 
 You need to use alternate constructors to the queue manager like properties and stuff.
 
 Have fun
  |  
 Sorry, could you explain with an example since I am not much familiar with C#.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Thu Mar 04, 2010 9:29 pm    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| A singleton is like a static modifier to the whole class. This means that there is only one MQEnvironment for the duration of the program / CLR. The values for this class are then frozen while a connection is in effect. 
 So in order to use multiple client connections simultaneously (at the same time) you need to use a different constructor for your queue manager, or run each connection in a different CLR. I suggest you use the one that accepts a properties class.
 
 Have fun
  _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | vikasdottv | 
			  
				|  Posted: Fri Mar 05, 2010 1:48 am    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 04 Mar 2010Posts: 4
 
 
 | 
			  
				| Thanks. I know the Singleton. Singleton will apply only for that application. My consumer (C++) and generator (C#) are two different applications written using two different languages. Any one application works when second application is not running irrespective of order. Both are two different application hence I assume they use their own address space given by opearting system and C++ app does not have any concept of CLR anyway.
 
 One more thing to note. I ran two different C++ application connecting to same Queue manager and that works. It is the problem only when I try to connect to same queue manager using two applications, one from C++ and second one from C# DotNet.
 
 Sorry, still i am not clear what you mean. Could you give the excat code if possible?
 
 Stack Trace:
 -------------------
 at IBM.WMQ.MQBase.throwNewMQException()
 at IBM.WMQ.MQQueueManager.Connect(String queueManagerName)
 at IBM.WMQ.MQQueueManager..ctor(String queueManagerName, String Channel, String ConnName)
 at DotNetMQLibrary.vikMQLibrary.connect() in D:\Vikas\vikMQLibrary.cs:line 166
 
 amqmdnet.dll details (used by generator C# dotnet app)
 ---------------------------------------------------------------------
 Assembly Version: 1.0.0.3
 Comments: WebSphere MQ Classes for .NET
 File Version: 1.0.0.3
 Language: Langauge Neutral
 Product Version: 6.0.2.3
 
 imqb23vn.dll details (used by consumer C++ app)
 ------------------------------------------------------------
 File Version: 6,002,0300,08028
 Comments: TIBM WebSphere MQ Classes for Windows
 Language: English (United States)
 Level: p600-203-080123
 Product Version: 6,0,2,3
 
 MQ Client installed on my PC
 ----------------------------------------
 H:\>dspmqver
 Name:        WebSphere MQ
 Version:     6.0.2.1
 CMVC level:  p600-201-070323
 BuildType:   IKAP - (Production)
 
 Regards
 Vikas
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Fri Mar 05, 2010 1:15 pm    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| Make sure you have no version mismatch with your MQ clients (dlls). I would only reference the MQ libraries and not deploy with the program.
 
 Your response is somewhat confusing because in .NET you have both C, C++, C# and J# coexisting in the CLR. The CLR is the equivalent of the JRE in java.
 
 Have fun
  _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | vikasdottv | 
			  
				|  Posted: Sun Mar 07, 2010 10:23 am    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 04 Mar 2010Posts: 4
 
 
 | 
			  
				| My C++ application is developed using VC++ 6.0 and C# app is using Visual Studio 2005. How do I find out the exact versions of the dlls being used by both applications?
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Sun Mar 07, 2010 12:55 pm    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| 
   
	| vikasdottv wrote: |  
	| My C++ application is developed using VC++ 6.0 and C# app is using Visual Studio 2005. How do I find out the exact versions of the dlls being used by both applications?
 |  
 That's a question for a windows forum...
  _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |