Set client reroute for applications that use DB2 databases


 

+

Search Tips   |   Advanced Search

Client reroute configures applications connected to a DB2 universal database to recover from a communication loss. The applications can continue to work with minimal interruption. Rerouting is possible if an alternate location is identified to the client connection.

This task assumes the following:

New feature: Client reroute for DB2 allows you to provide an alternate server location, in case the connection to the database server fails. If we decide to use client reroute with the persistence option, the alternate server information will persist across JVMs. In the event of an appserver crash, the alternate server information will not be lost when the appserver is restored and attempts to connect to the database

Without any configuration on the client side, a JDBC driver for DB2 supports the client reroute capability, if it is enabled, when the driver makes an initial connection to the DB2 server.

When the JDBC driver connects to a DB2 server that has an alternate server configured, the primary server sends information about the alternate server to the JDBC driver. If the connection to the primary server fails, the JDBC driver is able to reroute connections to the alternate server. If the client process crashes, however, the alternate server information is lost, and the client will need to connect to the primary server again. If the client cannot make an initial connection to the primary server, the client will have no knowledge of the alternate server and cannot reroute.

We can configure a DB2 data source in the appserver with the Alternate server name and Alternate port number fields, or with the data source custom properties...

clientRerouteAlternateServerName
clientRerouteAlternatePortNumber

If we have configured a DB2 data source as a Type 4 JDBC driver, we can use the field Client reroute server list JNDI name, or the data source custom property...

clientRerouteServerListJNDIName

...to enable persistence of the client reroute state.

Typically, when a connection is rerouted and the JDBC driver has connected to the alternate DB2 server, the alternate server sends information about its own alternate server to the JDBC driver. The JDBC driver will then have the information that is required to reroute the connection again if the alternate DB2 server is not available. Effectively, the server that was originally the alternate server is now the primary server, and a new alternate server has been established.

If we enable persistence for client reroute, this new state can be remembered.

If the appserver crashes and is restarted, the JDBC driver can connect to the DB2 server that was considered the primary server at the time of the crash. Without the persistence feature, the JDBC driver would have to start from the original server configuration and attempt to connect to the server that was originally considered the primary server.

Use the automatic client rerouting feature within the following DB2 configurable environments:

 

Procedure

  1. In the admin console, click...

    Resources | JDBC | Data sources | data_source | Data source properties

  2. In the DB2 automatic client reroute options section, fill in...

    Alternate server names

    List of alternate server name or names for the DB2 server. If more than one alternate server name is specified, the names must be separated by commas. For example:

    host1,host2

    Alternate port numbers

    List of alternate server port or ports for the DB2 server. If more than one alternate server port is specified, the ports must be separated by commas. For example:

    5000,50001

    Avoid trouble: Ensure that an equal number of entries must be specified for both alternate ports and hosts. Otherwise, a warning is displayed and client reroute is not enabled.

  3. To enable client reroute with the persistence option, fill in...

    Client reroute server list JNDI name

    ...which specifies the JNDI name used to bind the DB2 client reroute server list into the JNDI name space.

    The DB2 database server will use this name to look up the alternate server name list when the alternate server information is not already in memory.

    This option is not supported for Type 2 data sources. If we use a DB2 data source configured as a Type 2 JDBC driver, the JDBC driver uses a catalog to persist the client reroute information. If this property is configured with a Type 2 driver, the appserver will issue a warning.

    Use different JNDI names among different data sources. Otherwise, when you delete a data source, and the JNDI entry is removed from the name space, the other data sources that share the JNDI entry will be affected.

  4. Set the retry count and interval for the client reroute function.

    Retry interval for client reroute

    Amount of time, in seconds, between retries for automatic client reroute.

    Maximum retries for client reroute

    Maximum number of connection retries that are attempted by the automatic client reroute function if the primary connection to the server fails.

    The property is only used when Retry interval for client reroute is set.

  5. Click OK.

  6. Restart the appserver.

 

Next steps

To remove the client reroute information that is bound in JNDI, delete the data source.

We can also use the unbind feature with the test connection service to delete the JNDI binding for the client reroute function from the appserver's JNDI name space without deleting the data source...

  1. Select Unbind client reroute list from JNDI.
  2. Click OK.
  3. Save the configuration.
  4. Click Test connection for the data source.
  5. Deselect Unbind client reroute list from JNDI.
  6. Click OK.
  7. Save the configuration.

 

Related tasks


Set a JDBC provider and data source