Creating the main message flow
The Error Handler sample main message flow is supplied,
but if you prefer to create the message flow yourself, use the following instructions.
You must have created the error handling subflow before you can create the main message flow, see
Creating the error handling subflow.
- Create a new message flow called Main_Flow in the Error Handler Message Flows Message Broker project,
which you created when you created the subflow.
For instructions, see
Creating a message flow
in the WebSphere Message Broker documentation.
- In the Message Flow editor, add and rename the nodes listed in the following table.
For instructions, see
Adding a message flow node
in the WebSphere Message Broker documentation.
Palette drawers |
Node type |
Node name |
WebSphere MQ |
MQInput |
STAFF_IN |
WebSphere MQ |
MQOutput |
STAFF_FAIL |
Routing |
Filter |
Check Valid Staff Number |
Database |
Database |
Update Staff Database |
Construction |
Throw |
Throw |
WebSphere MQ |
MQOutput |
STAFF_OUT |
- Add the subflow to the main message flow:
- Ensure that the Main_Flow.msgflow file
is displayed in the Message Flow editor.
- Right-click the Message Flow editor,
click Add Subflow. The Add Subflow window opens.
- In the Add Subflow window, expand the
Error Handler Message Flows project,
expand (default), click
Error_Handler.msgflow, which is the subflow file.
Click OK.
- A node called Error_Handler, representing the subflow, is added to the Message Flow editor.
- Connect the nodes together as listed in the following table.
For instructions, see
Connecting message flow nodes
in the WebSphere Message Broker documentation.
To check that you have connected the nodes together correctly,
see the diagram in About the Error Handler sample.
Node name |
Terminal |
Connect to this node |
STAFF_IN |
Out |
Error_Handler |
Failure |
STAFF_FAIL |
Error Handler |
Out |
Check Valid Staff Number |
Check Valid Staff Number |
False |
Throw |
True |
Update Staff Database |
Update Staff Database |
Out |
STAFF_OUT |
Failure |
STAFF_OUT |
- Configure the node properties as listed in the following table.
Accept the default values for all properties unless an alternative value is listed in the table.
For instructions, see
Configuring a message flow node
in the WebSphere Message Broker documentation.
Node name |
Page |
Property |
Value |
STAFF_IN |
Basic |
Queue name |
STAFF_IN |
Input Message Parsing |
Message domain |
XML : For XML messages |
STAFF_FAIL |
Basic |
Queue name |
STAFF_FAIL |
Advanced |
Transaction mode |
Yes |
Update Staff Database |
Basic |
Data source |
STAFFDB |
Throw |
Basic |
Message number |
3001 |
Basic |
Message text |
Invalid staff number |
STAFF_OUT |
Basic |
Queue name |
STAFF_OUT |
Advanced |
Transaction mode |
Yes |
- In the Error Handler Message Flows project,
double-click the Main_Flow.esql file to open it in the ESQL editor.
Copy and paste the following ESQL code modules to the ESQL file, then save the file.
For more information, see
Developing ESQL
in the WebSphere Message Broker documentation.
CREATE FILTER MODULE Main_Flow_Filter
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
If Body.Staff.StaffNumber<='10' THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
END;
END MODULE;
CREATE DATABASE MODULE Main_Flow_Database
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
INSERT INTO Database.STAFF(STAFFNUM, LASTCHANGE, FIRSTNAME, LASTNAME)
VALUES(Body.Staff.StaffNumber, CURRENT_TIMESTAMP,
Body.Staff.NameInfo.FirstName, Body.Staff.NameInfo.LastName);
RETURN TRUE;
END;
END MODULE;
- Save the message flow.
Back to Building the Error Handler sample