Defining a TCP connection on Windows

Define a TCP connection by configuring a channel at the sending end to specify the address of the target, and by running a listener program at the receiving end.


Sending end

Specify the host name, or the TCP address of the target machine, in the Connection name field of the channel definition.

The port to connect to defaults to 1414. Port number 1414 is assigned by the Internet Assigned Numbers Authority to IBM MQ .

To use a port number other than the default, specify it in the connection name field of the channel object definition thus:
DEFINE CHANNEL('channel name') CHLTYPE(SDR) +   
          TRPTYPE(TCP) +
          CONNAME('OS2ROG3(1822)') +  
          XMITQ('XMitQ name') +  
          REPLACE
        
where OS2ROG3 is the DNS name of the remote queue manager and 1822 is the port required. (This must be the port that the listener at the receiving end is listening on.)

A running channel must be stopped and restarted to pick up any change to the channel object definition.

We can change the default port number by specifying it in the .ini file for IBM MQ for Windows:
TCP:
Port=1822
Note: To select which TCP/IP port number to use, IBM MQ uses the first port number it finds in the following sequence:
  1. The port number explicitly specified in the channel definition or command line. This number allows the default port number to be overridden for a channel.
  2. The port attribute specified in the TCP stanza of the .ini file. This number allows the default port number to be overridden for a queue manager.
  3. The default value of 1414. This is the number assigned to IBM MQ by the Internet Assigned Numbers Authority for both inbound and outbound connections.

For more information about the values you set using qm.ini, see Configuration file stanzas for distributed queuing.


Receiving on TCP

To start a receiving channel program, a listener program must be started to detect incoming network requests and start the associated channel. We can use the IBM MQ listener.

Receiving channel programs are started in response to a startup request from the sending channel.

To start a receiving channel program, a listener program must be started to detect incoming network requests and start the associated channel. We can use the IBM MQ listener.

To run the Listener supplied with IBM MQ, that starts new channels as threads, use the runmqlsr command.

A basic example of using the runmqlsr command:
runmqlsr -t tcp [-m QMNAME] [-p 1822]
The square brackets indicate optional parameters; QMNAME is not required for the default queue manager, and the port number is not required if you are using the default (1414). The port number must not exceed 65535. Note: To select which TCP/IP port number to use, IBM MQ uses the first port number it finds in the following sequence:
  1. The port number explicitly specified in the channel definition or command line. This number allows the default port number to be overridden for a channel.
  2. The port attribute specified in the TCP stanza of the .ini file. This number allows the default port number to be overridden for a queue manager.
  3. The default value of 1414. This is the number assigned to IBM MQ by the Internet Assigned Numbers Authority for both inbound and outbound connections.

For the best performance, run the IBM MQ listener as a trusted application as described in Running channels and listeners as trusted applications. See Restrictions for trusted applications for information about trusted applications


Use the TCP/IP SO_KEEPALIVE option

If you want to use the Windows SO_KEEPALIVE option you must add the following entry to your registry:
TCP:
KeepAlive=yes

For more information about the SO_KEEPALIVE option, see Checking that the other end of the channel is still available.

On Windows, the HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters registry value for the Windows KeepAliveTime option controls the interval that elapses before the connection is checked. The default is two hours.