Creating the XML_FlightQueryIn message flow

Use the following instructions to create the XML_FlightQueryIn 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 and XML_FlightQueryReply message flows. For instructions, see Creating the XML_FlightQueryOut message flow and Creating the XML_FlightQueryReply message flow.

To create and configure the XML_FlightQueryIn message flow:

  1. Create a new message flow called XML_FlightQueryIn.
    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 Type of node Name of node
    WebSphere MQ MQInput XML_FLIGHTQUERY_REPLIES
    WebSphere MQ MQOutput XML_FLIGHTQUERY_OUT
    WebSphere MQ MQOutput XML_FLIGHTQUERY_TIMEOUT
    WebSphere MQ MQOutput XML_FLIGHTQUERY_FAIL
    Transformation Compute BuildOutputMessage
    Transformation Compute ProcessTimeout
    Routing AggregateReply AggregateReplies
  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_FlightQueryIn message flow.
    Node name Terminal Connect to
    XML_FLIGHTQUERY_REPLIES Out AggregateReplies (In terminal)
    Catch XML_FLIGHTQUERY_FAIL
    AggregateReplies Out BuildOutputMessage
    Timeout ProcessTimeout
    BuildOutputMessage Out XML_FLIGHTQUERY_OUT
    ProcessTimeout Out XML_FLIGHTQUERY_TIMEOUT
  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_REPLIES Basic Queue name XML_FLIGHTQUERY_REPLIES
    (This is the queue where the control message was put by XML_FlightQueryOut.)
    Input Message Parsing Message domain XML : For XML messages
    (This tells the broker to use the generic XML parser.)
    AggregateReplies Basic Aggregate name FLIGHTDETAILSAGG
    (This name must match the Aggregate Name property of the Request details node in the FlightQuery_Out message flow.)
    Basic Unknown message timeout 60
    (This is the length of time for which messages that cannot be identified as replies are held before being propagated to the Unknown terminal.)
    Buildoutputmessage Basic ESQL module BuildOutputMessage
    (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_OUT 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_OUT
    (This is the local queue on which the message flow puts the message.)
    Processtimeout Basic ESQL module ProcessTimeout
    (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_TIMEOUT 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_TIMEOUT
    (This is the local queue on which the message flow puts the incomplete aggregated message if all the reply messages do not reach the Aggregate Replies node before the timeout that was specified in the Request Details node in the XML_FlightQueryOut message flow.)
    XML_FLIGHTQUERY_FAIL 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.)
  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_FlightQueryIn message flow
    -- ************************************************
    
    CREATE COMPUTE MODULE BuildOutputMessage
    	CREATE FUNCTION Main() RETURNS BOOLEAN
    	BEGIN
    		-- fix the aggregate reply message for output to a queue
    		SET OutputRoot.Properties = InputRoot.Properties;
    		CREATE NEXTSIBLING OF OutputRoot.Properties DOMAIN 'MQMD';
    		SET OutputRoot.MQMD.StrucId = MQMD_STRUC_ID;
    		SET OutputRoot.MQMD.Version = MQMD_CURRENT_VERSION;
    
    		DECLARE inflight REFERENCE TO InputRoot.ComIbmAggregateReplyBody.FlightDetails.XML.Flight;
    		DECLARE inpass REFERENCE TO InputRoot.ComIbmAggregateReplyBody.PassengerDetails.XML.ListOfPassengers;
    		CREATE FIELD OutputRoot.XML.FlightDetailsInfoResponse;
    		DECLARE outresp REFERENCE TO OutputRoot.XML.FlightDetailsInfoResponse;
    
    		-- populate the output message with flight info from the aggregate reply
    		CREATE FIRSTCHILD OF outresp.Flight TYPE NameValue NAME 'number' VALUE inflight.FLIGHTNO;
    		SET outresp.Flight.(XML.Attribute)Flightdate VALUE = inflight.FLIGHTDATE;
    		SET outresp.Flight.FirstClass.Capacity = inflight.TOTALFIRST;
    		SET outresp.Flight.FirstClass.Used = inflight.FIRSTCLASS;
    		SET outresp.Flight.FirstClass.Price = inflight.FIRSTPRICE;
    		SET outresp.Flight.EconomyClass.Capacity = inflight.TOTALECONOMIC;
    		SET outresp.Flight.EconomyClass.Used = inflight.ECONOMICCLASS;
    		SET outresp.Flight.EconomyClass.Price = inflight.ECONOMICPRICE;
    		SET outresp.Flight.Origin = inflight.STARTPOINT;
    		SET outresp.Flight.Destination = inflight.ENDPOINT;
    
    		-- populate the output message with passenger info from the aggregate reply		
    		DECLARE I INTEGER 1;
    		DECLARE J INTEGER CARDINALITY(inpass.*[]);
    		WHILE I <= J DO
    			SET outresp.ListOfPassengers.Passenger[I].ReservationNumber = inpass.PassengerDetails[I].RESERVATIONNO;
    			SET outresp.ListOfPassengers.Passenger[I].FirstName = inpass.PassengerDetails[I].FIRSTNAME;
    			SET outresp.ListOfPassengers.Passenger[I].LastName = inpass.PassengerDetails[I].LASTNAME;
    			SET outresp.ListOfPassengers.Passenger[I].Class = inpass.PassengerDetails[I].CLASSTYPE;
    			SET I = I + 1;
    		END WHILE;
    	RETURN TRUE;
    	END;
    END MODULE;
    
    CREATE COMPUTE MODULE ProcessTimeout
    	CREATE FUNCTION Main() RETURNS BOOLEAN
    	BEGIN
    		SET OutputRoot.Properties = InputRoot.Properties;
    		CREATE NEXTSIBLING OF OutputRoot.Properties DOMAIN 'MQMD';
    		SET OutputRoot.MQMD.StrucId = MQMD_STRUC_ID;
    		SET OutputRoot.MQMD.Version = MQMD_CURRENT_VERSION;
    		CREATE FIELD OutputRoot.XML.ComIbmAggregateReplyBody;
    		DECLARE timedout REFERENCE TO OutputRoot.XML.ComIbmAggregateReplyBody;
    		DECLARE reps REFERENCE TO InputRoot.ComIbmAggregateReplyBody;
    		MOVE reps FIRSTCHILD;
    		IF LASTMOVE(reps) THEN -- there will either be one reply, or none
    			SET timedout.TimedOut = reps.XML;
    		END IF;
    		RETURN TRUE;
    	END;
    END MODULE;
    
  6. Save the message flow.
You have now created the XML_FlightQueryIn message flow, which is the aggregate fan-in part of the XML_FlightQuery message flow. The XML_FlightQueryIn message flow works with the XML_FlightQueryOut and XML_FlightQueryReply 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.