As a first step, you need to download and install the following software packages:
- WebSphere MQ 7.0
- WebSphere Message Broker 6.1
- WebSphere Message Broker Toolkit V6.1
- solidDB 6.3
- DB2 9.5 Express-C
Each software package should be installed with the default options. This tutorial describes how to set up and configure them in the following sections.
For storing the log files, this tutorial uses a simple one-table approach with the following DDL statements for solidDB and DB2 (for production systems, enhanced features for the physical design could be applied):
Table 1. Database definitions
Listing 2. DDL statement for solidDB
Listing 3. DDL statement for DB2
solidDB at the front end does not require a schema name. For DB2 at the back end, use LOGAPP as the schema name.
All messages read from solidDB will be stored on WebSphere MQ. Therefore, you need dedicated queues that hold your messages.
As Table 2 shows, you need five new queues (note the prefix AL_ for "Application Logging"):
Table 2. Message queues
|These two queues will hold input messages from solidDB. The
difference between the two is the format of the containing log
|Q3: AL_OUTQUEUE||This queue is just a sink for messages.|
|Q4: AL_SUMMARYQUEUE||This queue gets all log summary messages for final storage.|
|Q5: AL_XMLFILES||Messages put in this queue will be inserted into DB2.|
Figure 3. A look into WebSphere MQ Explorer
Now you've set up your work environment and are ready to get started with application logging.
This tutorial uses WebSphere Message Broker Toolkit, an Eclipse-based tool for developing message flow applications. When you start the application for the first time, you need to set up a workplace folder for all project files.
Figure 4. Selecting a workspace
Now you need to create a new message flow project that holds all flows you develop later. Right-click on the empty project list, and select New > Message Flow Project:
Figure 5. Create new message flow project
A window pops up, asking you about the new project's name. Enter
logApp as name for the new project:
Figure 6. Create new message flow project
Next, set up a connection to the Message Broker domain instance you created earlier. Using this connection, you can interact with the Message Broker later on. To do this, right-click on your newly created project, and select New > Other:
Figure 7. New domain connection
In the opening window, look for and select the item Domain Connection:
Figure 8. New domain connection
You now need to enter the name of your Queue Manager. Since we used the default configuration, it is named WBRK61_DEFAULT_QUEUE_MANAGER, using port 2414:
Figure 9. New domain connection
logAppConnection as connection name.
After clicking Finish, confirm you want to create a new server
project in the opening message box:
Figure 10. New domain connection
You are now connected to the Message Broker. This is necessary to deploy projects and run them.
Next, let's import the XML Schema definitions you'll be using in Message Broker Toolkit. That way, WMB will be able to recognize and parse messages coming from solidDB.
Let's import the two files into WebSphere Message Broker Toolkit. First, you need to add a Message Set to your project. This set will hold all message definitions.
Right-click on the message flow project, and select New > Message Set:
Figure 11. New message set
Next, specify a name for the new message set. Since the workspace does not contain a message set project, you need to also enter a name for the new project. The new project, containing the new message set, will be added to your working set.
Name the message set
logAppMessages and the
Figure 12. New message set
You need to specify what types of data the new message set holds. Since you want to process XML data, select XML documents:
Figure 13. New message set
You have now entered all information needed, and the message set is ready to be created.
Figure 14. New message set
This message set will be the container for all custom message formats you use in this tutorial.
You are ready to import the XML Schema files into the message set. Right-click on your message set project, and select New > Message Definition File From > XML Schema File:
Figure 15. Import message definitions
Next, enter the path to the log file schema documents:
Figure 16. Import message definitions
Finally, choose the data types and messages you want to import. In this case, select all the boxes by clicking on the Select All button:
Figure 17. Import message definitions
You have successfully imported the first XML Schema definition into WebSphere Message Broker. To import the schema LogSummary.xsd to your workspace, repeat the steps above.
You need to modify the message set to support single Record elements in your message. Double-click on the LogFile message definition in your workspace to get the definitions to open in the right pane.
Figure 18. Modifying the message definition
You need to rename
Record, otherwise all the messages
containing a Record as root element will be named RecordType, instead
of Record. The renaming is already done in Figure 19:
Figure 19. Modifying the message definition
Now you can use the definitions to create mappings between different formats.