6

I wrote an application that connected to local queue manager using this function call:

MQQueueManager mqQMgr = new MQQueueManager("QM_QueueManagerName");

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

I can successfully connect to remote queue manager using MQ Explorer from my development PC using QM_ComputerName as queue manager 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?

Morvader
  • 2,317
  • 3
  • 31
  • 44
Joe Schmoe
  • 1,574
  • 4
  • 23
  • 48

2 Answers2

5

This is how I got it to work:

 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); // port number

   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)

   {

   }
Morvader
  • 2,317
  • 3
  • 31
  • 44
Joe Schmoe
  • 1,574
  • 4
  • 23
  • 48
2

Perhaps this sample code will help.

I linked to the V7 docs. Ideally you will be using both the V7 client and talking to a V7 server because the .Net functionality is much improved in these over V6. Also, V6 is end-of-life as of September 2011 so it would be good to go straight to v7 now and avoid the upgrade later.

If you need the v7 WMQ client, which includes the updated .Net samples and classes, go to IBM MQ Client Downloads page (requires IBM ID but is a free download).

UPDATE 20180810: Changed link to point to IBM's new page for all IBM MQ client downloads.

T.Rob
  • 31,522
  • 9
  • 59
  • 103
  • Yes, this is what I was looking for. I will post my code snippet too. – Joe Schmoe Nov 05 '10 at 18:06
  • Link is no longer available. – fasih.rana Jul 06 '18 at 12:17
  • IBM does not include 9.0 or 9.1 on that "all IBM MQ client downloads" page :(. Google search for MQC9 or MQC91 will find those. – JoshMc Aug 10 '18 at 20:12
  • The page seems to have suffered a regression. As an alternative to Google, I contacted Hursley and asked them to fix the page or retire it. As noted, these are delivered as SupportPacs so if the page goes away you can always to go the SupportPac page or Google if you know the SupportPac name. Hopefully though it will be fixed and monitored a bit closer. – T.Rob Aug 17 '18 at 21:35