ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » Connecting to remote queue manager using C# and .Net

Post new topic  Reply to topic Goto page 1, 2  Next
 Connecting to remote queue manager using C# and .Net « View previous topic :: View next topic » 
Author Message
JoeShcmoe115
PostPosted: Thu Nov 04, 2010 12:33 pm    Post subject: Connecting to remote queue manager using C# and .Net Reply with quote

Novice

Joined: 10 Aug 2010
Posts: 11

I wrote an application that connected to local queue using this

function call:

MQQueueManager mqQMgr = new MQQueueManager("QM_QueueName");

Now I need to connect to remote queue on another computer.

I can successfully connect to remote queue using MQ Explorer from my development PC using QM_ComputerName as queue name, S_ComputerName as channel and ComputerName as connection name. So it is accessible from my desktop.

However, when I try to connect via .Net I get MQRC_Q_MGR_NAME_ERROR no matter what I try.

I tried specifying

MQEnvironment.Hostname = "ComputerName";
MQEnvironment.Channel = "S_ComputerName ";

and then calling

mqQMgr = new MQQueueManager("QM_ComputerName");

I also tried calling

mqQMgr = new MQQueueManager("QM_ComputerName", "S_ComputerName", "ComputerName");

I get error in both cases.

Anyone can advise?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Nov 04, 2010 12:34 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

NMQ_MQ_LIB.
Back to top
View user's profile Send private message
JoeShcmoe115
PostPosted: Thu Nov 04, 2010 12:39 pm    Post subject: Reply with quote

Novice

Joined: 10 Aug 2010
Posts: 11

mqjeff wrote:
NMQ_MQ_LIB.

I am not sure what you mean
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Nov 04, 2010 12:41 pm    Post subject: Re: Connecting to remote queue manager using C# and .Net Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

JoeShcmoe115 wrote:
I wrote an application that connected to local queue using this

function call:

MQQueueManager mqQMgr = new MQQueueManager("QM_QueueName");

Now I need to connect to remote queue on another computer.


Pedantically, you're connecting to a queue manager. Hence the class you're using.

JoeShcmoe115 wrote:
I can successfully connect to remote queue using MQ Explorer from my development PC using QM_ComputerName as queue name, S_ComputerName as channel and ComputerName as connection name. So it is accessible from my desktop.


Calling a queue manager a queue will confuse people. Like me. So what you mean is you're got the queue manager to appear in MQExplorer by using these values?

JoeShcmoe115 wrote:
Anyone can advise?


What kind of connection are you using? If you're still using a binding connection then that's not going to work.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Nov 04, 2010 12:44 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

JoeShcmoe115 wrote:
mqjeff wrote:
NMQ_MQ_LIB.

I am not sure what you mean


It's a shorter way of asking my question about connection types, and also part of the answer. Look it up here
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
JoeShcmoe115
PostPosted: Thu Nov 04, 2010 12:55 pm    Post subject: Reply with quote

Novice

Joined: 10 Aug 2010
Posts: 11

Vitor: my original post was confusing. I did use "queue" instead of "queue manager". I updated original post to fix that.
Back to top
View user's profile Send private message
shashikanth_in
PostPosted: Thu Nov 04, 2010 6:30 pm    Post subject: Reply with quote

Centurion

Joined: 26 Feb 2009
Posts: 123

What port are you using? Is it the default port, 1414?
Back to top
View user's profile Send private message
JoeShcmoe115
PostPosted: Fri Nov 05, 2010 7:39 am    Post subject: Reply with quote

Novice

Joined: 10 Aug 2010
Posts: 11

shashikanth_in wrote:
What port are you using? Is it the default port, 1414?


Yes, default port - 1414
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Nov 05, 2010 7:46 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

JoeShcmoe115 wrote:
shashikanth_in wrote:
What port are you using? Is it the default port, 1414?


Yes, default port - 1414


And what was the outcome of the connection type question?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
JoeShcmoe115
PostPosted: Fri Nov 05, 2010 7:53 am    Post subject: Reply with quote

Novice

Joined: 10 Aug 2010
Posts: 11

Vitor wrote:
JoeShcmoe115 wrote:
shashikanth_in wrote:
What port are you using? Is it the default port, 1414?


Yes, default port - 1414


And what was the outcome of the connection type question?


As I mentioned in my OP - I get MQRC_Q_MGR_NAME_ERROR no matter what I try. I think I just can't get argument right.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Nov 05, 2010 7:54 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

JoeShcmoe115 wrote:
Vitor wrote:
JoeShcmoe115 wrote:
shashikanth_in wrote:
What port are you using? Is it the default port, 1414?


Yes, default port - 1414


And what was the outcome of the connection type question?


As I mentioned in my OP - I get MQRC_Q_MGR_NAME_ERROR no matter what I try. I think I just can't get argument right.


No, I meant our question about what connection type you're using. NMQ_MQ_LIB and so forth. As above.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
JoeShcmoe115
PostPosted: Fri Nov 05, 2010 8:04 am    Post subject: Reply with quote

Novice

Joined: 10 Aug 2010
Posts: 11

Vitor wrote:
JoeShcmoe115 wrote:
Vitor wrote:
JoeShcmoe115 wrote:
shashikanth_in wrote:
What port are you using? Is it the default port, 1414?


Yes, default port - 1414


And what was the outcome of the connection type question?


As I mentioned in my OP - I get MQRC_Q_MGR_NAME_ERROR no matter what I try. I think I just can't get argument right.


No, I meant our question about what connection type you're using. NMQ_MQ_LIB and so forth. As above.


Oh, I see what you mean now. I don't set NMQ_MQ_LIB or MQC.TRANSPORT_PROPERTY explicitly. This could be the source for my problems. Call me dumb, but I looked at help article that you provided and I am still not clear how to specify them. Can you provide a sample code snippet?
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Nov 05, 2010 8:15 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

JoeShcmoe115 wrote:
Oh, I see what you mean now. I don't set NMQ_MQ_LIB or MQC.TRANSPORT_PROPERTY explicitly. This could be the source for my problems.


Almost certainly. As shown here, if you don't explicitly set a connection type it's decided based on if you have server installed or not. Your OP talks about a local queue manager, implying you hav. Hence you're getting a server connection which won't work for what you're trying to do.

JoeShcmoe115 wrote:
Call me dumb, but I looked at help article that you provided and I am still not clear how to specify them.


Ok, you're dumb.

NMQ_MQ_LIB is an environment variable. I suspect you won't have got this far through a programming career without setting one of those. The documentation (link repeated above for your convienience) says:

Quote:
You can specify the transport property as follows:
By setting the property MQC.TRANSPORT_PROPERTY in a hashtable entry on an MQQueueManager constructor:
public MQQueueManager(String queueManagerName, Hashtable properties)


If you're still having trouble, code samples are supplied with the server install. If you didn't install them with the software check your media.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
JoeShcmoe115
PostPosted: Fri Nov 05, 2010 9:46 am    Post subject: Reply with quote

Novice

Joined: 10 Aug 2010
Posts: 11

Until the previous post the fact that NMQ_MQ_LIB is environment variable (and yes, I did set a lot of them over my career) was not mentioned. Neither it was mentioned in the help article. However your responses did point me in the correct direction and this is how I got it to work - hope it will help someone in the future (setting NMQ_MQ_LIB is not needed):

Code:
   MQQueueManager mqQMgr=null;

   Hashtable props = new Hashtable();
   props.Add(MQC.HOST_NAME_PROPERTY, "HostNameOrIP");
   props.Add(MQC.CHANNEL_PROPERTY, "ChannelName");
   props.Add(MQC.PORT_PROPERTY, 1414);
   props.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
   MQQueue mqQueue = null;

   try
   {
      mqQMgr = new  MQQueueManager("QueueManagerName", props);

   mqQueue = mqQMgr.AccessQueue(
               QueueName,
               MQC.MQOO_OUTPUT                   // open queue for output
               + MQC.MQOO_FAIL_IF_QUIESCING);   // but not if MQM stopping
   }
   catch (MQException mqe1)
   {
   }


Last edited by JoeShcmoe115 on Fri Nov 05, 2010 10:00 am; edited 1 time in total
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Nov 05, 2010 9:50 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

JoeShcmoe115 wrote:
this is how I got it to work - hope it will help someone in the future


And on behalf of those future readers I thank you for posting your solution.

JoeShcmoe115 wrote:
(setting NMQ_MQ_LIB is not needed)


This is true - it's an optional method perhaps more suited to a global connection solution.

Either way, glad you got it working.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » IBM MQ API Support » Connecting to remote queue manager using C# and .Net
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.