Defining which connection type to use

The connection type is determined by the setting of the connection name, channel name, the customization value NMQ_MQ_LIB and the property MQC.TRANSPORT_PROPERTY.

We can specify the connection name as follows:

  • Explicitly on an MQQueueManager constructor:
    public MQQueueManager(String queueManagerName, MQLONG Options, string Channel,
    string ConnName)
    
    public MQQueueManager(String queueManagerName, string Channel, string ConnName)
    
  • By setting the properties MQC.HOST_NAME_PROPERTY and, optionally, MQC.PORT_PROPERTY in a hashtable entry on an MQQueueManager constructor:
    public MQQueueManager(String queueManagerName, Hashtable properties)
    
  • As explicit MQEnvironment values
    MQEnvironment.Hostname
    
    MQEnvironment.Port (optional).
  • By setting the properties MQC.HOST_NAME_PROPERTY and, optionally, MQC.PORT_PROPERTY in the MQEnvironment.properties hashtable.

We can specify the channel name as follows:

  • Explicitly on an MQQueueManager constructor:
    public MQQueueManager(String queueManagerName, MQLONG Options, string Channel,
    string ConnName)
    
    public MQQueueManager(String queueManagerName, string Channel, string ConnName)
    
  • By setting the property MQC.CHANNEL_PROPERTY in a hashtable entry on an MQQueueManager constructor:
    public MQQueueManager(String queueManagerName, Hashtable properties)
    
  • As an explicit MQEnvironment value
    MQEnvironment.Channel
    
  • By setting the property MQC.CHANNEL_PROPERTY in the MQEnvironment.properties hashtable.

We 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)
    
  • By setting the property MQC.TRANSPORT_PROPERTY in the MQEnvironment.properties hashtable.

Select the connection type you require by using one of the following values:

  • MQC.TRANSPORT_MQSERIES_BINDINGS - connect as server
  • MQC.TRANSPORT_MQSERIES_CLIENT - connect as non-XA client
  • MQC.TRANSPORT_MQSERIES_XACLIENT - connect as XA client
  • MQC.TRANSPORT_MQSERIES_MANAGED - connect as non-XA managed client

We can set the customization value NMQ_MQ_LIB to explicitly choose the connection type as shown in the following table.

NMQ_MQ_LIB value Connection type
mqic.dll Connect as a non-XA client
mqicxa.dll Connect as an XA client
mqm.dll Connect as a server or as a non-XA client
managed Connect as a non-XA managed client
Note: Values of mqic32.dll and mqic32xa.dll are accepted as synonyms of mqic.dll and mqicxa.dll for compatibility with earlier releases. However, mqm.dll and mqm.pdb are only part of the client package from Version 7.1 onwards.

If you choose a connection type which is unavailable in the environment, for example you specify mqic32xa.dll and do not have XA support, IBM MQ .NET throws an exception.

Set NMQ_MQ_LIB to "managed" causes the client to use managed IBM MQ problem diagnostic tests, .NET data conversion, and other managed low-level IBM MQ functions.

All other values for NMQ_MQ_LIB cause the .NET process to use unmanaged IBM MQ problem diagnostic tests and data conversion, and other unmanaged low-level IBM MQ functions (assuming an IBM MQ MQI client or server is installed on the system).

IBM MQ.NET chooses the connection type as follows:
  1. If MQC.TRANSPORT_PROPERTY is specified, it connects according to the value of MQC.TRANSPORT_PROPERTY. Note, however, that setting MQC.TRANSPORT_PROPERTY to MQC.TRANSPORT_MQSERIES_MANAGED does not guarantee that the client process runs managed. Even with this setting, the client is not managed in the following cases:

    • If another thread in the process has connected with MQC.TRANSPORT_PROPERTY set to something other than MQC.TRANSPORT_MQSERIES_MANAGED.
    • If NMQ_MQ_LIB is not set to "managed", problem diagnostic tests, data conversion, and other low-level functions are not fully managed (assuming an IBM MQ MQI client or server is installed on the system).

  2. If a connection name has been specified without a channel name, or a channel name has been specified without a connection name, it throws an error.
  3. If both a connection name and a channel name have been specified:

    • If NMQ_MQ_LIB is set to mqic32xa.dll, it connects as an XA client.
    • If NMQ_MQ_LIB is set to managed, it connects as a managed client.
    • Otherwise it connects as a non-XA client.

  4. If NMQ_MQ_LIB is specified, it connects according to the value of NMQ_MQ_LIB.
  5. If an IBM MQ server is installed, it connects as a server.
  6. If an IBM MQ MQI client is installed, it connects as a non-XA client.
  7. Otherwise, it connects as a managed client.

Parent topic: Connection differences