Skip to main content

IBM Websphere MQ - Automatic client reconnection - Middleware News

Automatic client reconnection

You can make your client applications reconnect automatically, without writing any additional code, by configuring a number of components.
Automatic client reconnection is inline. The connection is automatically restored at any point in the client application program, and the handles to open objects are all restored.
In contrast, manual reconnection requires the client application to re-create a connection using MQCONN orMQCONNX, and to reopen objects. Automatic client reconnection is suitable for many, but not all client applications.
Table 1 lists the earliest release of WebSphere® MQ client support that must be installed on a client workstation. You must upgrade client workstations to one of these levels for an application to use automatic client reconnection. Table 2 lists other requirements to enable automatic client reconnection.
With program access to reconnection options, a client application can set reconnection options. Except for JMS and XMS clients, if a client application has access to reconnection options, it can also create an event handler to handle reconnection events.
An existing client application might be able to benefit from reconnection support, without recompilation and linking:
  • For a non-JMS client, set the mqclient.ini environment variable DefRecon to set reconnection options. Use a CCDT to connect to a queue manager. If the client is to connect to a multi-instance queue manager, provide the network addresses of the active and standby queue manager instances in the CCDT.
  • For a JMS client, set the reconnection options in the connection factory configuration. When you use the WebSphere MQ Resource adapter or a JMS Client that is integrated in a Java™ EE Environment, automatic client reconnection might not be available. There are restrictions in some of the managed environments, for more information see WebSphere MQ automatic client reconnection with WebSphere MQ classes for JMS.
Table 1. Supported clients
Client interfaceClientProgram access to reconnection optionsReconnection support
Messaging APIsC, C++, COBOL, Unmanaged Visual Basic, XMS (Unmanaged XMS on Windows)7.0.17.0.1
JMS (JSE, and Java EE client container and managed containers)7.0.1.37.0.1.3
WebSphere MQ classes for JavaNot supportedNot supported
Managed XMS and managed .NET clients: C#, Visual Basic7.17.1
Other APIsWindows Communication Foundation (Unmanaged )Not supported7.0.1
Windows Communication Foundation (Managed )Not supportedNot supported
Axis 1Not supportedNot supported
Axis 2Not supported7.0.1.3
HTTP (web 2.0)Not supported7.0.1.3
  1. Set managed or unmanaged mode in the WCF binding configuration.
Automatic reconnection has the following configuration requirements:
Table 2. Automatic reconnection configuration requirements
ComponentRequirementEffect of not meeting requirement
WebSphere MQ MQI client installationSee Table 1MQRC_OPTIONS_ERROR
WebSphere MQ Server installationLevel 7.0.1MQRC_OPTIONS_ERROR
ChannelSHARECNV > 0MQRC_ENVIRONMENT_ERROR
Application environmentMust be threadedMQRC_ENVIRONMENT_ERROR
MQIOne of:
  • MQCONNX with MQCNO Options set toMQCNO_RECONNECT orMQCNO_RECONNECT_Q_MGR.
  • Defrecon=YES|QMGR in mqclient.ini
  • In JMS set the CLIENTRECONNECTOPTIONS property of the connection factory.
MQCC_FAILED when a connection is broken or queue manager ends or fails.
Figure 1 shows the main interactions between components that are involved in client reconnection.
Figure 1. Automatic client reconnection

Client application

The client application is a WebSphere MQ MQI client.
  • By default clients are not automatically reconnected. Enable the automatic client reconnection by setting the MQCONNX MQCNO Option MQCNO_RECONNECT or MQCNO_RECONNECT_Q_MGR.
  • Many applications are written in such a way that they are able to take advantage of auto-reconnection with no additional coding. Enable automatic reconnection for existing programs, without making any coding changes, by setting the DefRecon attribute in the channels stanza of the mqclient.ini configuration file.
  • Use one of these three options:
    1. Modify the program so that the logic is unaffected by reconnection. For example, you might have to issue MQI calls within the sync point, and resubmit backed-out transactions.
    2. Add an event handler to detect reconnection, and restore the state of the client application when the connection is reestablished.
    3. Do not enable auto-reconnection: instead, disconnect the client and issue a newMQCONN or MQCONNX MQI call to find another queue manager instance that is running in the same queue manager group.
    For further details about these three options, see Application recovery.
  • Reconnecting to a queue manager of the same name does not guarantee that you have reconnected to the same instance of a queue manager.
    Use an MQCNO option MQCNO_RECONNECT_Q_MGR , to reconnect to an instance of the same queue manager.
  • A client can register an event handler so that it can be informed the state of reconnection. TheMQHCONN passed in the event handler cannot be used. The following reason codes are provided:
    MQRC_RECONNECTING
    The connection failed, and the system is attempting to reconnect. You receive multipleMQRC_RECONNECTING events if multiple reconnect attempts are made.
    MQRC_RECONNECTED
    The reconnection made and all handles successfully reestablished.
    MQRC_RECONNECT_FAILED
    The reconnection was not successful.
    MQRC_RECONNECT_QMID_MISMATCH
    A reconnectable connection specified MQCNO_RECONNECT_Q_MGR and the connection attempted to reconnect to a different queue manager.
    MQRC_RECONNECT_Q_MGR_REQD
    An option, such MQMO_MATCH_MSG_TOKEN in an MQGET call, was specified in the client program that requires reconnection to the same queue manager.
  • A reconnectable client is able to reconnect automatically only after connecting. That is, theMQCONNX call itself is not tried again if it fails. For example, if you receive the return code 2543 - MQRC_STANDBY_Q_MGR from MQCONNX, reissue the call after a short delay.
    MQRC_RECONNECT_INCOMPATIBLE
    This reason code is returned when the application tries to use MQPMO_LOGICAL_ORDER (with MQPUT and MQPUT1) or MQGMO_LOGICAL_ORDER (with MQGET) when reconnect options are set. The reason for returning the reason code is to make sure that applications never use reconnect in such cases.
    MQRC_CALL_INTERRUPTED
    This reason code is returned when the connection breaks during the execution of Commit call and the client reconnects. An MQPUT of a persistent message outside the sync point also results in the same reason code being returned to the application.

Multi-instance queue managers

Simplify restarting WebSphere MQ MQI client applications, after a multi-instance queue manager has activated its standby instance, by using automatic client reconnection.
The standby instance of a multi-instance queue manager is typically at a different network address to the active instance. Include the network addresses of both the instances in the client connection definition table (CCDT). Either provide a list of network addresses for the CONNAME parameter, or define multiple rows for the queue manager in the CCDT.
Commonly, WebSphere MQ MQI clients reconnect to any queue manager in a queue manager group. Sometimes you want a WebSphere MQ MQI client to reconnect only to the same queue manager. It might have an affinity to a queue manager. You can prevent a client from reconnecting to a different queue manager. Set the MQCNOoption, MQCNO_RECONNECT_Q_MGR. The WebSphere MQ MQI client fails if it reconnects to a different queue manager. If you set the MQCNO option, MQCNO_RECONNECT_Q_MGR, do not include other queue managers in the same queue manager group. The client returns an error if the queue manager it reconnects to is not the same queue manager as the one it connected to.

Queue manager groups

You can select whether the client application always connects and reconnects to a queue manager of the same name, to the same queue manager, or to any of a set of queue managers that are defined with the sameQMNAME value in the client connection table.
  • The queue manager name attribute, QMNAME , in the client channel definition is the name of a queue manager group.
  • In your client application, if you set the value of the MQCONN or MQCONNX QmgrName parameter to a queue manager name, the client connects only to queue managers with that name. If you prefix the queue manager name with an asterisk(*), the client connects to any queue manager in the queue manager group with the same QMNAME value. For a full explanation, see Queue manager groups in the CCDT.

Queue sharing groups

Automatic client reconnection to z/OS® queue sharing groups, uses the same mechanisms for reconnection as any other environment. The client will reconnect to the same selection of queue managers as is configured for the original connection. For example, when using the client channel definition table the administrator should ensure that all entries in the table, resolve to the same z/OS queue sharing group.

Client and server channel definitions

Client and server channel definitions define the groups of queue managers a client application can reconnect to. The definitions govern the selection and timing of reconnections, and other factors, such as security; see the related topics. The most relevant channel attributes to consider for reconnection are listed in two groups:
Client connection attributes
Connection affinity (AFFINITY)AFFINITY
Connection affinity.
Client channel weight (CLNTWGHT)CLNTWGHT
Client channel weight.
Connection name (CONNAME)CONNAME
Connection information.
Heartbeat interval (HBINT)HBINT
Heartbeat interval. Set the heartbeat interval on the server connection channel.
Keepalive Interval (KAINT)KAINT
Keepalive interval. Set the keepalive interval on the server connection channel.
Note that KAINT applies to z/OS only.
Queue manager name (QMNAME)QMNAME
Queue manager name.
Server connection attributes
Heartbeat interval (HBINT)HBINT
Heartbeat interval. Set the heartbeat interval on the client connection channel.
Keepalive Interval (KAINT)KAINT
Keepalive interval. Set the keepalive interval on the client connection channel.
Note that KAINT applies to z/OS only.
KAINT is a network layer heartbeat, and HBINT is a WebSphere MQ heartbeat between the client and the queue manager. Setting these heartbeats to a shorter time serves two purposes:
  1. By simulating activity on the connection, network layer software that is responsible for closing inactive connections is less likely to shut down your connection.
  2. If the connection is shut down, the delay before the broken connection is detected, is shortened.
The default TCP/IP keepalive interval is two hours. Consider setting the KAINT and HBINT attributes to a shorter time. Do not assume that the normal behavior of a network suits the needs of automatic reconnection. For example, some firewalls can shut down an inactive TCP/IP connection after as little as 10 minutes.

Network connectivity

Only network failures that are passed to the WebSphere MQ MQI client by the network, are handled by the automatic reconnection capability of the client.
  • Reconnections performed automatically by the transport are invisible to WebSphere MQ.
  • Setting HBINT helps to deal with network failures that are invisible to WebSphere MQ.

Queue managers and WebSphere MQ listeners

Client reconnection is triggered by server failure, queue manager failure, network connectivity failure, and by an administrator switching over to another queue manager instance.
  • If you are using a multi-instance queue manager, an additional cause of client reconnection occurs when you switch control from the active queue manager instance to a standby instance.
  • Ending a queue manager using the default endmqm command, does not trigger automatic client reconnection. Add the -r option on the endmqm command to request automatic client reconnection, or the -s option to transfer to a standby queue manager instance after shutting down.

WebSphere MQ MQI client automatic reconnection support

If you use the automatic client reconnection support in the WebSphere MQ MQI client, the client application automatically reconnects and continues processing without you issuing an MQCONN or MQCONNX MQI call to reconnect to the queue manager.
  • Automatic client reconnection is triggered by one of the following occurrences:
    • queue manager failure
    • ending a queue manager and specifying the -r, reconnect, option on the endmqmcommand
  • The MQCONNX MQCNO options control whether you have enabled the automatic client reconnection. The options are described in Reconnection options.
  • Automatic client reconnection issues MQI calls on behalf of your application to restore the connection handle and the handles to other open objects, so that your program can resume normal processing after it has processed any MQI errors that resulted from the broken connection. SeeRecovery of an automatically reconnected client .
  • If you have written a channel exit program for the connection, the exit receives these additional MQI calls.
  • You can register a reconnection event handler, which is triggered when reconnection begins and when it finishes.
Although reconnection takes no more than a minute, reconnection can take longer because a queue manager might have numerous resources to manage. During this time, a client application might be holding locks that do not belong to WebSphere MQ resources. There is a timeout value you can configure to limit the time a client waits for reconnection. The value (in seconds) is set in the mqclient.ini file.
Channels:
    MQReconnectTimeout = 1800
No reconnection attempts are made after the timeout has expired. When the system detects that the timeout has expired it returns a MQRC_RECONNECT_FAILED error.

Comments

adsrerrapop

Popular posts from this blog

IBM Websphere MQ interview Questions Part 5

MQ Series: - It is an IBM web sphere product which is evolved in 1990’s. MQ series does transportation from one point to other. It is an EAI tool (Middle ware) VERSIONS:-5.0, 5.1, 5.3, 6.0, 7.0(new version). The currently using version is 6.2 Note: – MQ series supports more than 35+ operating systems. It is platform Independent. For every OS we have different MQ series software’s. But the functionality of MQ series Default path for installing MQ series is:- C: programfiles\BM\clipse\SDK30 C: programfiles\IBM\WebsphereMQ After installation it will create a group and user. Some middleware technologies are Tibco, SAP XI. MQ series deals with two things, they are OBJECTS, SERVICES. In OBJECTS we have • QUEUES • CHANNELS • PROCESS • AUTHENTICATION • QUERY MANAGER. In SERVICES we have LISTENERS. Objects: – objects are used to handle the transactions with the help of services. QUEUE MANAGER maintains all the objects and services. QUEUE: – it is a database structure

IBM Websphere MQ Reason code list / mq reason codes / websphere mq error codes / mq error messages

Reason code list ================= The following is a list of reason codes, in numeric order, providing detailed information to help you understand them, including: * An explanation of the circumstances that have caused the code to be raised * The associated completion code * Suggested programmer actions in response to the code * 0 (0000) (RC0): MQRC_NONE * 900 (0384) (RC900): MQRC_APPL_FIRST * 999 (03E7) (RC999): MQRC_APPL_LAST * 2001 (07D1) (RC2001): MQRC_ALIAS_BASE_Q_TYPE_ERROR * 2002 (07D2) (RC2002): MQRC_ALREADY_CONNECTED * 2003 (07D3) (RC2003): MQRC_BACKED_OUT * 2004 (07D4) (RC2004): MQRC_BUFFER_ERROR * 2005 (07D5) (RC2005): MQRC_BUFFER_LENGTH_ERROR * 2006 (07D6) (RC2006): MQRC_CHAR_ATTR_LENGTH_ERROR * 2007 (07D7) (RC2007): MQRC_CHAR_ATTRS_ERROR * 2008 (07D8) (RC2008): MQRC_CHAR_ATTRS_TOO_SHORT * 2009 (07D9) (RC2009): MQRC_CONNECTION_BROKEN * 2010 (07DA) (RC2010): MQRC_DATA_LENGTH_ERROR * 2011 (07DB) (RC2011): MQRC_DYNAMIC_Q_NAME_ERROR * 2012 (07DC) (RC201

IBM WebSphere MQ – Common install/uninstall issues for MQ Version on Windows - Middleware News

Creating a log file when you install or uninstall WebSphere MQ WebSphere MQ for Windows is installed using the Microsoft Installer (MSI). If you install the MQ server or client through launchpad , MQPARMS or setup.exe , then a log file is automatically generated in %temp% during installation. Alternatively you can supply parameters on the installation MSI command msiexec to generate a log file, or enable MSI logging system-wide (which generates MSI logs for all install and uninstall operations). If you uninstall through the Windows Add/Remove programs option, no log file is generated. You should either uninstall from the MSI command line and supply parameters to generate a log file, or enable MSI logging system-wide (which generates MSI logs for all install and uninstall operations). For details on how to enable MSI logging, see the following article in the WebSphere MQ product documentation: Advanced installation using msiexec For details on how to enable system-w