Creating the XML_FlightQueryReply message flow

Use the following instructions to create the XML_FlightQueryReply message flow. For more detailed instructions, click the links provided at the end of each step.

Before you create the XML_FlightQueryReply message flow, you must create the XML_FlightQueryOut message flow. For instructions, see Creating the XML_FlightQueryOut message flow.

To create and configure the XML_FlightQueryReply message flow:

  1. Create a new message flow called XML_FlightQueryReply.
    For instructions, see Creating a message flow.
  2. 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 XML_FLIGHTQUERY_FLIGHT
    WebSphere MQ MQInput XML_FLIGHTQUERY_PASSENGERS
    WebSphere MQ MQOutput XML_FLIGHTQUERY_FAIL_1
    WebSphere MQ MQOutput XML_FLIGHTQUERY_FAIL_2
    WebSphere MQ MQReply MQMD_ReplyToQ
    Transformation Compute GetFlightDetails
    Transformation Compute GetPassengerDetails
  3. Connect the nodes together as shown 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 XML_FlightQueryReply message flow.
    Node name Terminal Connect to
    XML_FLIGHTQUERY_FLIGHT Out GetFlightDetails
    Catch XML_FLIGHTQUERY_FAIL_1
    XML_FLIGHTQUERY_PASSENGERS Out GetPassengerDetails
    Catch XML_FLIGHTQUERY_FAIL_2
    GetFlightDetails Out MQMD_ReplyToQ
    GetPassengerDetails Out MQMD_ReplyToQ
  4. Configure the node properties as shown in the following table. Accept the default values for all properties unless an alternative value is shown in the table.
    For instructions, see Configuring a node.
    Node name Page Property Value
    XML_FLIGHTQUERY_FLIGHT Basic Queue name XML_FLIGHTQUERY_FLIGHT
    (This is the local queue from which the message flow takes the message.)
    Input Message Parsing Message domain XML : For XML messages
    (This tells the broker to use the generic XML parser.)
    XML_FLIGHTQUERY_PASSENGERS Basic Queue name XML_FLIGHTQUERY_PASSENGERS
    (This is the local queue from which the message flow takes the message.)
    Input Message Parsing Message domain XML : For XML messages
    (This tells the broker to use the generic XML parser.)
    GetFlightDetails Basic Data source RESERVDB
    (This is the database used by this node.)
    Basic ESQL module GetFlightDetails
    (This is the name of the ESQL module used by this node during processing. The name must match the name in the CREATE COMPUTE MODULE statement in the ESQL file.)
    GetPassengerDetails Basic Data source RESERVDB
    (This is the database used by this node.)
    Basic ESQL module GetPassengerDetails
    (This is the name of the ESQL module used by this node during processing. The name must match the name in the CREATE COMPUTE MODULE statement in the ESQL file.)
    XML_FLIGHTQUERY_FAIL_1 Basic Queue name
    (You do not need to specify the name of the queue manager because the queue is defined on the same queue manager as the broker.)
    XML_FLIGHTQUERY_FAIL
    (This is where the message flow puts the message if the processing fails.)
    XML_FLIGHTQUERY_FAIL_2 Basic Queue name
    (You do not need to specify the name of the queue manager because the queue is defined on the same queue manager as the broker.)
    XML_FLIGHTQUERY_FAIL
    (This is where the message flow puts the message if the processing fails.)
    MQMD_ReplyToQ You do not need to set any properties for this node.
    The node uses the ReplyToQ and the ReplyToQMgr fields in the MQMD header of the message.
  5. In the XML Airline Message Flows project, double-click the 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.
    -- ************************************************
    -- * ESQL for the XML_FlightQueryReply message flow
    -- ************************************************
    
    CREATE COMPUTE MODULE GetFlightDetails
    	CREATE FUNCTION Main() RETURNS BOOLEAN
    	BEGIN
    		SET OutputRoot = InputRoot;
    		SET OutputRoot.XML.FlightQuery = NULL;
    		CREATE FIELD OutputRoot.XML.Flight;
    		DECLARE outflight REFERENCE TO OutputRoot.XML.Flight;
    		DECLARE query REFERENCE TO InputRoot.XML.FlightQuery;		
    		-- populate the output message with flight info from the database
    		SET OutputRoot.XML.Flight[] =
    			(SELECT T.* FROM Database.XMLFLIGHTTB AS T
    				WHERE T.FLIGHTNO = query.FlightNumber
    				AND T.FLIGHTDATE = query.FlightDate);
    		SET outflight.STARTPOINT = TRIM(outflight.STARTPOINT);
    		SET outflight.ENDPOINT = TRIM(outflight.ENDPOINT);
    		RETURN TRUE;
    	END;
    END MODULE;
    
    CREATE COMPUTE MODULE GetPassengerDetails
    	CREATE FUNCTION Main() RETURNS BOOLEAN
    	BEGIN
    		SET OutputRoot = InputRoot;
    		SET OutputRoot.XML.FlightQuery = NULL;		
    		CREATE FIELD OutputRoot.XML.ListOfPassengers;
    		DECLARE outpass REFERENCE TO OutputRoot.XML.ListOfPassengers;
    		DECLARE query REFERENCE TO InputRoot.XML.FlightQuery;
    		-- populate the output message with passenger info from the database
    		SET outpass.PassengerDetails[] =
    			(SELECT T.* FROM Database.XMLPASSENGERTB AS T
    				WHERE T.FLIGHTNO = query.FlightNumber
    				AND T.FLIGHTDATE = query.FlightDate);
    		DECLARE I INTEGER 1;
    		DECLARE J INTEGER CARDINALITY(outpass.*[]);
    		WHILE I <= J DO
    			SET outpass.PassengerDetails[I].LASTNAME = TRIM(outpass.PassengerDetails[I].LASTNAME);
    			SET outpass.PassengerDetails[I].FIRSTNAME = TRIM(outpass.PassengerDetails[I].FIRSTNAME);
    			SET I = I + 1;
    		END WHILE;
    		RETURN TRUE;
    	END;
    END MODULE;
  6. Save the message flow.
You have now created the XML_FlightQueryReply message flow, which is the aggregate reply part of the XML_FlightQuery message flow. The XML_FlightQueryReply message flow works with the XML_FlightQueryOut and XML_FlightQueryIn message flows to request information about a specific flight and the passengers who have reserved seats on that flight.

Main Page icon   Back to Building the Airline Reservations sample.