Configuring databases for coordinated message flows using DB2

If your message flow interacts with a DB2 database, and you want to coordinate the updates made to the database with other actions within the message flow, configure your broker to manage these updates.

Before you start:

To complete this task, you must have completed the following task:

If you are using DB2 Version 8 on Linux (x86 platform), UNIX, or Windows systems, DB2 Version 8.1 Fix Pack 5 is the minimum level that is supported and you must configure the following values.
  1. Database configuration:
    1. Start of changeYou must set the transaction processor monitor name (TP_MON_NAME) to MQ on Windows by issuing the command:
      db2 update dbm cfg using TP_MON_NAME MQ
      You must not set this parameter if you are using a 64-bit DB2 instance. The setting of this variable is optional on 32-bit instances of DB2 on Linux and UNIX. End of change
    2. Ensure that you have adequate connection resources; either use all TCP/IP connections or enable extended shared memory.
    3. To enable shared memory support for DB2, take the following steps:
      1. Turn on extended shared memory in the DB2 server:
        export EXTSHM=ON
        db2set DB2ENVLIST=EXTSHM
        db2stop
        db2start
      2. Turn on shared memory support in the broker environment:
        mqsistop broker
        export EXTSHM=ON (in the profile of all broker environments)
        mqsistart broker
  2. Queue Manager configuration:

    The toc (Thread of Control) specified in the XAOpenString determines the mode in which the Resource Manager (DB2) runs. The ThreadOfControl stanza specifies the mode in which the Transaction Manager (WebSphere MQ) runs. Specify explicit values to ensure that both products run in THREAD mode.

Start of change

Using DB2 with only 32-bit execution groups

If you want to use DB2 in coordinated transactions:

  • If you use DB2 Version 8, use the supplied switch file; a file called db2swit is provided for each supported operating system. These files are installed in the directory <install_dir>/sample/xatm.
  • If you prefer to build your own files, follow the instructions in the section "DB2 configuration" in the WebSphere MQ System Administration Guide. You can also find details of how to configure XA resource definitions in this book.

Refer to the information provided for the version of WebSphere MQ that you have installed:

  • For coordination by WebSphere MQ Version 5.0:

    The following examples show what you must include in the XAResourceManager stanza in the qm.ini file on Linux and UNIX systems, and the equivalent information for Windows.

    In each example:
    • install_dir is the location in which the WebSphere Message Broker run time is installed
    • MyDataSource is the name of the data source to which you want to connect
    • MyUserId is the user name with which you want to connect to the data source
    • MyPassword is the password associated with the user name

    On Linux and UNIX (AIX, HP-UX, and Solaris):

    XAResourceManager:
    Name=DB2
    SwitchFile=install_dir/sample/xatm/db2swit
    XAOpenString=db=MyDataSource,uid=MyUserId,pwd=MyPassword,toc=t
    XACloseString=
    ThreadOfControl=THREAD
    On Windows, set the following values on the Resources page of the properties dialog box for your WebSphere MQ queue manager:
    SwitchFile: C:\Program Files\IBM\MQSI\6.0\sample\xatm\db2swit.dll
    XAOpenString: db=MyDataSource,uid=MyUserId,pwd=MyPassword,toc=t
    ThreadOfControl: THREAD
  • For coordination by WebSphere MQ Version 6.0:

    The following examples show what you must include in the XAResourceManager stanza in the qm.ini file on Linux and UNIX systems, and the equivalent information for Windows.

    On Linux and UNIX (AIX, HP-UX, and Solaris):

    1. Create the following symbolic links (on Linux, create only the first symbolic link shown):
      ln –s install_dir/sample/xatm/db2swit /var/mqm/exits/db2swit
      ln –s install_dir/sample/xatm/db2swit64 /var/mqm/exits64/db2swit
    2. Include the following code in the XAResourceManager stanza in the qm.ini file
      XAResourceManager:
      Name=DB2
      SwitchFile=db2swit
      XAOpenString=db=MyDataSource,uid=MyUserId,pwd=MyPassword,toc=t
      XACloseString=
      ThreadOfControl=THREAD

    On Windows, set the following values on the Resources page of the properties dialog box for your WebSphere MQ queue manager. This example assumes that you have installed WebSphere Message Broker in the directory C:\WMQI:

    SwitchFile: C:\wmqi\sample\xatm\db2swit
    XAOpenString: db=MyDatabase,uid=MyUserId,pwd=MyPassword,toc=t
    ThreadOfControl: THREAD
End of change

Using DB2 with only 64-bit execution groups

If you want to use DB2 in coordinated transactions:

  • If you use DB2 Version 8, use the supplied switch file; a file called db2swit64 is provided for each supported platform. This file is installed as install_dir/sample/xatm/db2swit64.
  • If you prefer to build your own files, follow the instructions in the section "DB2 configuration" in the WebSphere MQ System Administration Guide. You can also find details of how to configure XA resource definitions in this book.

The following examples show what you must include in the XAResourceManager stanza in the qm.ini file on UNIX systems.

  1. Create the following symbolic link:
    ln –s install_dir/sample/xatm/db2swit64 /var/mqm/exits64/db2swit
  2. Include the following code in the XAResourceManager stanza in the qm.ini file
    XAResourceManager:
    Name=DB2
    SwitchFile=db2swit
    XAOpenString=db=MyDataSource,uid=MyUserId,pwd=MyPassword,toc=t
    XACloseString=
    ThreadOfControl=THREAD
Related concepts
Message flows overview