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.

  1. 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.
  2. 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
  3. Add the subflow to the main message flow:
    1. Ensure that the Main_Flow.msgflow file is displayed in the Message Flow editor.
    2. Right-click the Message Flow editor, click Add Subflow. The Add Subflow window opens.
    3. 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.
    4. A node called Error_Handler, representing the subflow, is added to the Message Flow editor.
  4. 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
  5. 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
  6. 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;
  7. Save the message flow.

Back to Building the Error Handler sample