Creating the message flow
The Video Rental sample message flow is supplied, but if you prefer to create the message flow yourself, follow the instructions below:
- In the Message Brokers Toolkit, switch to the Broker Application Development perspective.
-
Create a new message flow project called Video Message Flows.
For instructions, see Creating a message flow project.
- Create a new message flow called Video_Test.
For instructions, see Creating a message flow.
- In the Message Flow editor, add and rename the nodes listed in the following table. For instructions, see Adding a node.
Palette drawers |
Node type |
Node name |
WebSphere MQ |
MQInput |
VIDEO_XML_IN |
WebSphere MQ |
MQInput |
VIDEO_TDS_IN |
WebSphere MQ |
MQInput |
VIDEO_CWF_IN |
WebSphere MQ |
MQOutput |
VIDEO_OUT |
WebSphere MQ |
MQOutput |
VIDEO_FAIL |
Transformation |
Compute |
Extract Fields |
- Connect the nodes together as listed in the following table. For instructions, see Connecting nodes.
To check that you have connected the nodes together correctly, see the figure in About the Video message flow.
Node name |
Terminal |
Connect to this node |
VIDEO_XML_IN |
Failure |
VIDEO_FAIL |
Out |
Extract Fields |
Catch |
VIDEO_FAIL |
VIDEO_TDS_IN |
Failure |
VIDEO_FAIL |
Out |
Extract Fields |
Catch |
VIDEO_FAIL |
VIDEO_CWF_IN |
Failure |
VIDEO_FAIL |
Out |
Extract Fields |
Catch |
VIDEO_FAIL |
Extract Fields |
Out |
VIDEO_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 node.
For the VIDEO_XML_IN, VIDEO_TDS_IN, and VIDEO_CWF_IN nodes, you must set the message set identifier property. Every message set has a unique identifier. To find the identifier of the message set you have created, action the following:
- In the Broker Development view, expand the navigation tree: Video Message Flows > Video Message Set > messageSet.mset.
- Double-click messagetSet.mset to open it.
- Your unique message set identifier is displayed in the Message Set ID field.
Node name |
Page |
Property |
Value |
VIDEO_XML_IN |
Basic |
Queue name |
VIDEO_XML_IN |
Input Message Parsing |
Message domain |
MRM |
Input Message Parsing |
Message set |
(Select your unique message set identifier) |
Input Message Parsing |
Message type |
Customer |
Input Message Parsing |
Message format |
XML1 |
VIDEO_TDS_IN |
Basic |
Queue name |
VIDEO_TDS_IN |
Input Message Parsing |
Message domain |
MRM |
Input Message Parsing |
Message set |
(Select your unique message set identifier) |
Input Message Parsing |
Message type |
Customer |
Input Message Parsing |
Message format |
TDS1 |
VIDEO_CWF_IN |
Basic |
Queue name |
VIDEO_CWF_IN |
Input Message Parsing |
Message domain |
MRM |
Input Message Parsing |
Message set |
(Select your unique message set identifier) |
Input Message Parsing |
Message type |
Customer |
Input Message Parsing |
Message format |
CWF1 |
VIDEO_FAIL |
Basic |
Queue name |
VIDEO_FAIL |
Extract Fields |
Basic |
ESQL module |
Video_Test_Compute |
VIDEO_OUT |
Basic |
Queue name |
VIDEO_OUT |
- In the Video Message Flows project, double-click the Video_Test.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.
CREATE COMPUTE MODULE Video_Test_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- This ESQL extracts some of the fields from the input message
-- just to demonstrate the references used for fields in different
-- namespaces
SET OutputRoot = InputRoot;
DECLARE addr NAMESPACE 'http://www.ibm.com/AddressDetails';
DECLARE brw NAMESPACE 'http://www.ibm.com/BorrowedDetails';
DECLARE I INTEGER;
SET OutputRoot.MRM.Name = InputRoot.MRM.Name;
SET OutputRoot.MRM.addr:Address = InputBody.addr:Address;
IF InputRoot.MRM.ID ='P' THEN
SET OutputRoot.MRM.PassportNo = InputBody.PassportNo;
ELSEIF InputRoot.MRM.ID ='D' THEN
SET OutputRoot.MRM.DrivingLicenseNo=InputBody.DrivingLicenseNo;
ELSEIF InputRoot.MRM.ID ='C' THEN
SET OutputRoot.MRM.CreditCardNo=InputBody.CreditCardNo;
END IF;
SET I=1;
WHILE I<= CARDINALITY(InputBody.brw:Borrowed.*[]) DO
SET OutputRoot.MRM.brw:Borrowed[I].VideoTitle = InputBody.brw:Borrowed[I].VideoTitle;
SET OutputRoot.MRM.brw:Borrowed[I].DueDate=InputBody.brw:Borrowed[I].DueDate + INTERVAL '1' DAY;
SET OutputRoot.MRM.brw:Borrowed[I].Cost=InputBody.brw:Borrowed[I].Cost*2;
SET I=I+1;
END WHILE;
SET OutputRoot.MRM.Magazine = InputBody.Magazine;
RETURN TRUE;
END;
END MODULE
- Save the message flow.
You have now created the Video message flow.
Back to sample home