Setting up the Error Handler sample

When you have imported the Error Handler sample, you must configure the sample to use transactionality before you can deploy the sample to the broker.

To set up the Error Handler sample to use transactionality:

  1. Set up ODBC (Linux only)
  2. Enable transactionality with DB2 (Windows and Linux)
  3. Enable transactionality in WebSphere MQ (Windows and Linux):
  4. Deploy the sample to the broker (Windows and Linux)

Setting up the ODBC drivers on Linux

This step must be performed on Linux but not on Windows. So skip this step if you are working only on Windows.

To set up the ODBC drivers on Linux:

  1. Open the /var/mqsi/odbc/.odbc.ini file in a text editor.
  2. In the .odbc.ini file, locate the line that says: [ODBC Data Source] then insert the following lines below it:
    ERRORDB= IBM DB2 ODBC Driver
    STAFFDB= IBM DB2 ODBC Driver
  3. Add the following stanzas to the .odbc.ini file:
    [ERRORDB]
    Driver=/opt/IBM/db2/V8.1/lib/libdb2.so
    Description=ERRORDB DB2 ODBC Database
    Database=ERRORDB
    
    [STAFFDB]
    Driver=/opt/IBM/db2/V8.1/lib/libdb2.so
    Description=STAFFDB DB2 ODBC Database
    Database=STAFFDB

The ODBC drivers are now configured correctly.

Enabling transactionality with DB2

To configure DB2 to use transactionality:

  1. Start the DB2 Control Center:
  2. In the navigation tree, where hostname is the name of your computer and DB2 is the name of the database instance, expand All Systems > computername > Instances > DB2. On Windows, DB2 is typically DB2; on Linux, DB2 is typically db2inst1.
  3. Right-click DB2, then click Configure Parameters... The DBM Configuration dialog opens.
  4. In the DBM Configuration dialog, scroll down the dialog to the Environment section. In the Keyword column, click TP_MON_NAME.
  5. For TP_MON_NAME, click the cell in the Value column, then click the ellipses (...) in the same cell. The Change DBM Configuration Parameter dialog opens.
  6. In the Change DBM Configuration Parameter dialog, from the Transaction processor monitor name list, click IBM MQSeries, then click OK.
  7. Click OK to close the DBM Configuration dialog. A message is displayed prompting you to restart DB2: click Close to close the message.
  8. In the navigation tree, right-click DB2, then click Stop. A dialog prompts you to confirm that you want to stop DB2 and disconnect all applications that are currently accessing a DB2 database. Click OK to continue, then wait for DB2 to stop.
  9. In the navigation tree, right-click DB2, then click Start, then wait for DB2 to start again.

Enabling transactionality in WebSphere MQ Version 6.0

Define the STAFFDB database as an XA resource manager to the broker's queue manager. The broker's queue manager acts as the transaction manager. The steps to configure the queue manager are different than if you use WebSphere MQ Version 5.3.

To define the STAFFDB database as an XA resource manager:

  1. Copy the DB2 switch file from the WebSphere Message Broker installation to the WebSphere MQ V6.0 installation:

    DB2 must be installed in its default location for the DB2 switch file to work correctly.

  2. Configure the broker's queue manager, WBRK61_DEFAULT_QUEUE_MANAGER, to add a new resource manager, STAFFDB:
    1. Start WebSphere MQ Explorer:
      • On Windows, click Start > Programs > IBM WebSphere MQ > WebSphere MQ Explorer.
      • On Linux, on the command line, type: strmqcfg
    2. In the Navigator view of WebSphere MQ Explorer, expand the tree to display the broker's queue manager, WBRK61_DEFAULT_QUEUE_MANAGER.
    3. Right-click WBRK61_DEFAULT_QUEUE_MANAGER, then click Properties... The queue manager's Properties dialog opens.
    4. On the XA resource managers page, click Add..., then enter the details in the following table.
      Field name Value
      Name DB2 Error Handler
      Switch file db2swit
      XAOpenString STAFFDB,userid,password,toc=t
      where userid is your WebSphere Message Broker user name, and password is the associated password.
      XACloseString
      DB2 does not require an XA close string.
      Thread of Control From the list, click Thread.
    5. Stop and start the broker's queue manager. In WebSphere MQ Explorer, right-click WBRK61_DEFAULT_QUEUE_MANAGER, then click Stop; right-clickWBRK61_DEFAULT_QUEUE_MANAGER, then click Start. Ensure that the queue manager started without errors.

    The STAFFDB database is defined as the XA resource manager to the broker's queue manager, WBRK61_DEFAULT_QUEUE_MANAGER.

Enabling transactionality in WebSphere MQ Version 5.3

Define the STAFFDB database as an XA resource manager to the broker's queue manager. The broker's queue manager acts as the transaction manager. The steps to configure the queue manager are different than if you use WebSphere MQ Version 6.0. Also, in WebSphere MQ Version 5.3, there is no graphical equivalent of WebSphere MQ Explorer, so you must directly edit the queue managers ini file, as described in the following instructions.

To define the STAFFDB database as an XA resource manager:

  1. Copy the DB2 switch file from the WebSphere Message Broker installation to the WebSphere MQ V5.3 installation:

    DB2 must be installed in its default location for the DB2 switch file to work correctly.

  2. Configure the broker's queue manager, WBRK61_DEFAULT_QUEUE_MANAGER, to add a new resource manager, STAFFDB: The STAFFDB database is defined as the XA resource manager to the broker's queue manager, WBRK61_DEFAULT_QUEUE_MANAGER.

Deploying the Error Handler sample to the broker

  1. In the Message Brokers Toolkit, switch to the Broker Administration perspective.
  2. Create a new broker archive (bar) file and add Main_Flow.msgflow to the bar file:
    1. In the Broker Administration perspective, click File > New > Message Broker Archive. The New Message Broker Archive wizard opens.
    2. In the New Message Broker Archive wizard, select the server project and enter a name for the bar file, then click Finish. The new bar file is created and opens in the Broker Archive editor.
    3. In the Broker Archive editor, click the Add button. The Add to Broker Archive dialog opens.
    4. In the Add to Broker Archive dialog, click the Error Handler Message Flows project, then select Main_Flow.msgflow. Click OK. The Main_Flow.msgflow file is added to the bar file.
  3. Configure the message flow to run as a coordinated transaction:
    1. Click the Configure tab at the bottom of the Broker Archive editor to switch to the Configure page.
    2. Click Main_Flow.cmf to highlight it.
    3. Select the Coordinated Transaction check box.
    4. Click the Content tab to return to the main page in the editor.
  4. Press Ctrl+S to save the bar file.
  5. Ensure that the Message Brokers Toolkit is connected to the Configuration Manager.
  6. In the Domains view, create a new execution group called ErrorHandler.
  7. In the Broker Administration Navigator, right-click the bar file that you created, then click Deploy File... The Deploy a BAR File dialog opens.
  8. In the Deploy a BAR File dialog, click the ErrorHandler execution group, then click OK. The Main_Flow.msgflow file is deployed to the broker.

You can now run the Error Handler sample. See Running the sample.

Back to sample home