This article describes a case study using IBM® WebSphere® Business Integration Message Broker V5 (hereafter called WebSphere Message Broker) to automate the creation of a configurable broker archive file. It starts with a set of previously defined message flows for an airline reservation system. It then describes how to use promotion and configurability to make the flow more reusable, how to use scripts to add these flows to a broker archive file, how to deploy them in a set of execution groups. Throughout, it recommends best practices and provides reusable scripts.
Case study: Airline reservation system
The following lists the process for developing a message flow application with WebSphere Message Broker:
- Create a conceptual model of the system.
- Instantiate this model as a set of flows containing nodes and messages in the WebSphere Message Broker tool.
- Create a deployable broker archive (BAR) file.
- Configure and deploy the BAR file to a test environment.
- Configure and deploy the deployable artifact to a production system.
The case study is an airline reservation system. Assume that the first four steps in the process outlined above have been completed. The focus is on the configuration and deployment of a BAR file.
The airline sample is based on a scenario of an airline booking system, like those used by travel agencies. It demonstrates how to use some of the features provided by WebSphere Message Broker for Multi-platforms V5.0. You can run the airline sample to simulate the following tasks:
- Reserve seats on a flight.
- Request information about a passenger.
- Request information about a specific flight and its passenger list.
- Cancel a reservation.
Flows are designed to implement the airline reservation system features. Nodes with suitable functions are selected. Every flow contains at least one input node, whose characteristic have been defined. Other nodes, such as Compute, are chosen to determine the path that a message follows based on the content of the messages, to provide checks or examination of the message, or to update and query databases. Output nodes are also used to direct certain messages to different nodes and queue.
This article uses the XML version of the airline sample, which includes seven individual message flows and six self-defining XML input messages, which are supplied so that you can test the message flows. These flows handle functions such as reserving seats, updating reservation databases, and requesting information about reservations, flights, and passengers. The messages that run through these flows are generic self-defining XML in nature. The necessary queues and databases are created using scripts provided in the WebSphere Message Broker online help. For more information on flows and messages, see the WebSphere Message Broker online help.
Configuring and promoting the flow
Configurable properties provide a mechanism for system object names (such as database connections, or the name of an MQSeries queue) to be configured without recompiling a flow application. The configurability feature is empowered by another feature, the property promotion. Property promotion is an existing feature of flow programming that exists independent of the configurability feature. The promotion feature allows the flow developer to specify that several properties are set by a single promoted property. This way, a property that is identified as configurable is promoted so it is set together with other attributes. The value of a promoted configurable property is set only on the promoted instance. This is because a flow designer uses promotion to control the setting of a property value in a hierarchical composition. Setting the value of the original definition of a configurable property and bypassing the property promotion model means that configurability could undermine the flow developers intent. When a configurable property is promoted, its configurability is not lost with the promotion. The promoted property is also configurable.
Promoted properties are configurable if their original definition specifies they are configurable. This means that when a configurable property is promoted, it continues to be configurable. To do this, the configurable status of a Promoted Property is computed as the inclusive OR of the configurable status of all the attributes promoted to the promoted property. If a configurable and a not-configurable property are promoted to the same promoted property, both values are configurable together. An example of a promotion of a property is shown in Figure 1.
Figure 1. Promoting data source property to upper level flow
The concept of configurable properties is powerful since it allows last minute modification of system objects. It means you can package a BAR file once, test it on a development machine using one set of parameter values, and then deploy it to the production environment using another, without recompiling. If you want to redeploy the same BAR file to multiple production environments, change the configurable parameters as required, without the need to go back to a development environment.
Using configurability and promotion
In the airline reservation system, the configurable properties are the dataSource property of the Compute node and the queueManagerName of the MQOutput node. The dataSource property is the system name of a database connection. In Microsoft® Windows®, it is the name of an ODBC connection. The queueManagerName represents the name of the MQSeries queue manager associated with the broker, and queues of interest. Because this property is the name of a system object, the development team and the administrators can specify the value of these properties in the deployment descriptor during a publish operation. Further, each developer can configure their workspace to provide their own overrides that are correct within their developer sandbox.
In the XML_BuildReplyMessage message flow, the dataSource property of the "Build Single Message", and "Propagate Multiple Messages" Compute nodes, and the "Multiple Or Single Message?" Filter node are promoted to the same BuildReplyMessage_dataSource node. This same dataSource property is promoted again in the XML_Reservation message flow, along with the dataSource properties of the "Update Passenger table" Compute node and "Update Flight Table" Database Node. Figure 2 shows the XML_Reservation flow using the WebSphere Message Broker message flow editor.
Figure 2. XML_Reservation flow
Deploying the flow application
At the XML_Reservation flow level, the dataSource attribute is set to RESERVDB, the name of the DB2 ODBC connection that is already established. Similarly, the queueManagerName properties of the "XML_RESERVATION_OUT" and "XML_RESERVATION_FAIL" MQOutput nodes are promoted to the same queueManagerName attribute at the XML_Reservation flow, and set to QM_myMachineName. The promotion process was done using the Property promotion dialog as shown in Figure 3.
Figure 3. Property promotion dialog
You develop a flow application using nested flows, property promotion, and configurable properties. The flow application is developed by a team that uses configurable properties to customize the application for their development sandbox. Once the flow application is fully developed, it is redeployed; first to system test, then to production.
You can build the BAR file using the command line tool, mqsibar. You can use scripts to create this BAR file. You can use the provided sample scripts to create and deploy a BAR file. The first sample script called setProperties.bat sets environment variables used by the second sample scripts called
createBar.bat. The last script, deployBar.bat, deploys the BAR file to the desired broker.
In Listing 1, the setProperties.bat file sets up the environment variables required by the
createBar.bat script. In this example, you are setting the home directory for the WebSphere Message Broker tool, the installation directory, the name of the BAR file to create, and the flows to add to the BAR file.
Listing 1. setProperties.bat script file
rem Properties for Command Line WBIMB execution set WBIMB_HOME=C:\Progra~1\IBM\WebSph~1 set WORKSPACE=%WBIMB_HOME%\eclipse\workspace set BARNAME=C:\temp\deployable.bar set BARFILES=airlin~1\XML_BuildReplyMessage.msgflow airlin~1\XML_CancelReservation.msgflow airlin~1\XML_FlightQueryIn.msgflow airlin~1\XML_FlightQueryOut.msgflow airlin~1\XML_FlightQueryReply.msgflow airlin~1\XML_PassengerQuery.msgflow airlin~1\XML_Reservation.msgflow |
In Listing 2, the batch file invokes the setProperties.bat file to setup the required environment variables, then invokes the mqsicreatebar executable to create the BAR file.
Listing 2. createBar.bat script file
@ECHO OFF rem Broker Archive (bar) file command line creation SETLOCAL rem Set the configurable properties for this creation CALL setProperties.bat ECHO. ECHO Broker Archive Command Line Creation ECHO -------------------------------------------------- ECHO WBIMB home=%WBIMB_HOME% ECHO. ECHO WORKSPACE=%WORKSPACE% ECHO BARNAME=%BARNAME% ECHO FILES=%BARFILES% ECHO --------------------------------------------------- "%WBIMB_HOME%\eclipse\mqsicreatebar.exe" -data %WORKSPACE% -b %BARNAME% -o %BARFILES% ENDLOCAL |
Finally, you can deploy the newly created BAR file from the command line, using the
mqsideploy.bat script provided by the installation in the bin directory. A sample script using
mqsideploy.bat can automate the process of deploying a known set of BAR files. The script specifies which broker to deploy to, using a specific execution group and configuration manager properties file. The script calls
setProperties.bat again to get the name of the BAR file to deploy, and then calls
mqsideploy.bat to attempt to deploy the BAR file as shown in Listing 3.
Listing 3. deployBar.bat script file
@echo off setlocal rem Properties for Bar deployment call setProperties.bat set BROKER=WBRK_BROKER set EXECGRP=exec2 set CFGFILE=%WORKSPACE%\test\WBRK_QM.configmgr set BACK=%cd% echo -------------------------------------------------- echo Broker Archive Deployment echo BROKER = %BROKER% echo EXECUTION GROUP = %EXECGRP% echo BAR FILE = %BARNAME% echo CONFIG FILE = %CFGFILE% echo CURRENT DIR = %cd% echo -------------------------------------------------- cd %WBIMB_HOME%\bin "mqsideploy.bat" -b %BROKER% -e %EXECGRP% -bar %BARNAME% -connection %CFGFILE% cd %BACK% endlocal |
Versioning of flows within BAR files
Passing the flows to the system administrator for deployment in the system, then having a way to define the version number for the flows included in the BAR file, and even for the BAR file itself, is useful. WebSphere Message Broker does not include direct support for versioning, since each development organization uses its own scheme, most likely tied to the version control software used internally. However, by using the scripts provided with this article, you can assign version numbers to both the flows and the BAR file.
The recommended approach is to append the source control version number to the flow name when adding it to the BAR file. You can automate this process using the -v option provided by the mqsibar utility. Every time a new version of a message flow or message set is added to the BAR file, the name of the recently added file appends with "_" (underscore) and the version number. Next time, when the newer copy of the file is compiled and added to the broker archive file, the version number is replaced by the new value.
You can do another layer of versioning by appending version numbers to the name of the BAR file. Using the option
-b (to specify the BAR file name), you can modify the target BAR file name and append a version number to it. The BAR file is uniquely identified based on the version numbers of the constituent flows, but this additional layer is still useful when delivering BAR files between development and deployment teams.
Using scripts to configure and build BAR files is an efficient approach that you can easily implement. By using these scripts, you can build BAR files efficiently and quickly move from one configuration to another by simply changing a parameter in the command line. In addition, you can version these BAR files and avoid losing historical information. This method avoids using a slow user interface and unnecessary typos.
| Name | Size | Download method |
|---|---|---|
| sample_files.zip | 4 KB | FTP |
Information about download methods
Hamzeh Zawawy is a software engineer at the IBM Toronto Lab, Ontario, Canada. He is the lead developer of the Broker Archive and RAD components of the WebSphere Business Integration Message Broker.
Ross McKegney is a software engineer at the IBM Toronto Lab, Ontario, Canada. He is the lead developer of the Member Management component of WebSphere Commerce.




