WebSphere

Example: Tracking messages using a relational database with Message Logger mediation primitive

This example shows you how to create a database to track messages through a mediation flow, and to track transaction rollbacks.

Context

When you install and configure WebSphere Process Server, or WebSphere Enterprise Service Bus, you can create database resources that are suitable for the Message Logger mediation primitive.

You can let the Message Logger mediation primitive use the Common database, and the default schema. However, you can also use the createMessageLoggerResource.jacl script to create databases, and database resources, for the Message Logger. For example, you might use the createMessageLoggerResource.jacl script if you were migrating from a previous version, and did not want to use the Common database for the Message Logger. You might also use the createMessageLoggerResource.jacl script, on z/OS® or i5/OS, to create additional schema qualifiers for the Common database. You could then compartmentalize Message Logger data, using schemas.

Requirements

This example requires basic knowledge of wsadmin, the Java™ Command Language (Jacl) toolkit, and the ability to create and deploy a mediation flow that can roll back transactions.

Wsadmin is a non-graphical scripting client that lets you perform administrative tasks from a script. At runtime, the wsadmin scripting client is found in the install_root\bin directory, on a Windows system; and in the install_root/bin directory, on a Linux or UNIX system.

Code sample

The following code samples create database resources that you can use with the Message Logger mediation primitive. You can use the Message Logger to track messages through a mediation flow, keeping an audit trail of transaction rollbacks.

The following examples create a local Derby database called EsbLogMedDB, a database schema called ESBLOG, and a table called MSGLOG.

The default database name is EsbLogMedDB, therefore if you want to specify your own name use the -dbName option. For other configurations you can specify options including: dbType dbSchemaName dbServerPort.

Windows example:
wsadmin.bat -f createMessageLoggerResource.jacl -createDb 
Linux and UNIX example:
wsadmin.sh -f createMessageLoggerResource.jacl -createDb 

Further information

The Message Logger mediation primitive is a supplied mediation primitive that can be used to record messages in a relational database, as they pass through a mediation flow. A mediation primitive can run in a new transaction so that even if the flow is rolled back a record is kept of the attempt. You can use a second Message Logger mediation primitive inside the main flow of the transaction to keep a complete record of every message, and a record of whether it was rolled back. In order to use the Message Logger primitive you must have the appropriate database resources available.

After you have run messages through the flow and caused some of them to roll back, you can review the logs. There is no specialized mediation primitive provided to read the logs, but you can use a Database Lookup mediation primitive, a Custom Mediation primitive or a Java component. Alternatively, you can read the logs using a separate tool.

The Derby database comes with an interactive JDBC scripting tool called ij, which you can use to view the messages you have logged. It is assumed that you installed your runtime product on a Windows system at C:\ESB and your profile is ESB01.

If you log messages to the database you created in the previous example (EsbLogMedDB), to table MSGLOG under a schema qualifier of ESBLOG, then you can view all logged messages in the following way:
  1. Stop the application that uses the Derby database. This is necessary because Derby only allows one user at a time.
  2. Start ij. On Windows: C:\ESB\derby\bin\embedded\ij
  3. Connect to the database: connect 'C:/ESB/profiles/ESB01/databases/EsbLogMedDB';
  4. Select all logged messages: select * from ESBLOG.MSGLOG;
If you log messages to the common database (WPRCSDB), to table MSGLOG under a schema qualifier of ESBLOG, then you can view all logged messages in the following way:
  1. Stop the application that uses the Derby database. This is necessary because Derby only allows one user at a time.
  2. Start ij. On Windows: C:\ESB\derby\bin\embedded\ij
  3. Connect to the database: connect 'C:/ESB/profiles/ESB01/databases/WPRCSDB';
  4. Select all logged messages: select * from ESBLOG.MSGLOG;

reference Reference topic

Terms of use | Feedback


Timestamp icon Last updated: 20 June 2010 00:39:51 BST (DRAFT)


http://publib.boulder.ibm.com/infocenter/dmndhelp/v6r2mx/topic//com.ibm.wbit.help.medprim620.doc/ref/example_messloggprim.html
Copyright IBM Corporation 2005, 2010. All Rights Reserved.
This information center is powered by Eclipse technology (http://www.eclipse.org).
iDoc on