Setting up the WebSphere MQ environment

Note:
This step is not necessary when using WebSphere MQ classes for .NET in server bindings mode. In that case, go directly to Connecting to a queue manager. Before you use the client connection to connect to a queue manager, you must set up the MQEnvironment.

The C based WebSphere MQ clients rely on environment variables to control the behavior of the MQCONN call. The .NET programming interface allows you to use the NMQ_MQ_LIB environment variable but also includes a class MQEnvironment. This class allows you to specify the following details that are to be used during the connection attempt:

To specify the channel name and host name, use the following code:

MQEnvironment.Hostname = "host.domain.com";
MQEnvironment.Channel  = "client.channel";

By default, the clients attempt to connect to a WebSphere MQ listener at port 1414. To specify a different port, use the code:

MQEnvironment.Port = nnnn;