Using IBM's sample code, I am able to connect to a single instance queue manager, and I am able to connect to a single instance of a multi-instance queue manager, but I cannot connect to the multi-instance queue manager.
I am using version 9.2 of ibm-mq-client.
When I use a single server as the host name everything works, but if I change it to a list ("iib-mq1.it.wd.com,iib-mq2.it.wd.com") it fails at the line:
MQQueueManager qMgr = new MQQueueManager(qManager, connectionProperties);
with the error:
2298 MQRC_FUNCTION_NOT_SUPPORTED
My code:
using IBM.WMQ;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace QueueInterface
{
class MQSample
{
// The type of connection to use, this can be:-
// MQC.TRANSPORT_MQSERIES_BINDINGS for a server connection.
// MQC.TRANSPORT_MQSERIES_CLIENT for a non-XA client connection
// MQC.TRANSPORT_MQSERIES_XACLIENT for an XA client connection
// MQC.TRANSPORT_MQSERIES_MANAGED for a managed client connection
const String connectionType = MQC.TRANSPORT_MQSERIES_MANAGED;
// Define the name of the queue manager to use (applies to all connections)
const String qManager = "TST_MQMI_QM";
// Define the name of your host connection (applies to client connections only)
//const String hostName = "iib-mq1.it.wd.com";
const String hostName = "iib-mq1.it.wd.com,iib-mq2.it.wd.com";
// Define the name of the channel to use (applies to client connections only)
const String channel = "FHS.IIB.TS";
const String userName = "iib-tst-usr";
const String password = "randomPassword";
const String port = "1212";
const String queue = "TEST.ADD.FULL";
/// <summary>
/// Initialise the connection properties for the connection type requested
/// </summary>
/// <param name="connectionType">One of the MQC.TRANSPORT_MQSERIES_ values</param>
static Hashtable init(String connectionType)
{
Hashtable connectionProperties = new Hashtable();
// Add the connection type
connectionProperties.Add(MQC.TRANSPORT_PROPERTY, connectionType);
// Set up the rest of the connection properties, based on the
// connection type requested
switch (connectionType)
{
case MQC.TRANSPORT_MQSERIES_BINDINGS:
break;
case MQC.TRANSPORT_MQSERIES_CLIENT:
case MQC.TRANSPORT_MQSERIES_XACLIENT:
case MQC.TRANSPORT_MQSERIES_MANAGED:
connectionProperties.Add(MQC.HOST_NAME_PROPERTY, hostName);
connectionProperties.Add(MQC.PORT_PROPERTY, port);
connectionProperties.Add(MQC.CHANNEL_PROPERTY, channel);
connectionProperties.Add(MQC.USER_ID_PROPERTY, userName);
connectionProperties.Add(MQC.PASSWORD_PROPERTY, password);
connectionProperties.Add(MQC.USE_MQCSP_AUTHENTICATION_PROPERTY, true);
break;
}
return connectionProperties;
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static int Main(string[] args)
{
try
{
Hashtable connectionProperties = init(connectionType);
// Create a connection to the queue manager using the connection
// properties just defined
MQQueueManager qMgr = new MQQueueManager(qManager, connectionProperties);
// Set up the options on the queue we want to open
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
// Now specify the queue that we want to open,and the open options
MQQueue system_default_local_queue = qMgr.AccessQueue(queue, openOptions);
// Define an IBM MQ message, writing some text in UTF format
MQMessage hello_world = new MQMessage();
hello_world.WriteUTF("Sample Message");
// Specify the message options
MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the defaults,
// same as MQPMO_DEFAULT
// Put the message on the queue
system_default_local_queue.Put(hello_world, pmo);
// Close the queue
system_default_local_queue.Close();
// Disconnect from the queue manager
qMgr.Disconnect();
}
//If an error has occurred,try to identify what went wrong.
//Was it an IBM MQ error?
catch (MQException ex)
{
Console.WriteLine("An IBM MQ error occurred: {0}", ex.ToString());
}
catch (System.Exception ex)
{
Console.WriteLine("A System error occurred: {0}", ex.ToString());
}
return 0;
}//end of start
}//end of sample
}
Instead of specifying a host and port you need to specify a connection name list. In below example I removed the variables to keep it simple.
Change:
connectionProperties.Add(MQC.HOST_NAME_PROPERTY, "iib-mq1.it.wd.com,iib-mq2.it.wd.com");
connectionProperties.Add(MQC.PORT_PROPERTY, 1212);
To:
connectionProperties.Add(MQC.CONNECTION_NAME_PROPERTY,"iib-mq1.it.wd.com(1212),iib-mq2.it.wd.com(1212)")