Creating the XML_PassengerQuery message flow

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

To create and configure the XML_PassengerQuery message flow:

  1. Create a new message flow called XML_PassengerQuery.
    For instructions, see Creating a message flow in the IBM Integration Bus 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 IBM Integration Bus documentation.
    Palette drawers Node type Node name
    WebSphere MQ MQInput XML_PASSENGERQUERY_IN
    WebSphere MQ MQOutput XML_PASSENGERQUERY_OUT
    WebSphere MQ MQOutput XML_PASSENGERQUERY_FAIL_1
    WebSphere MQ MQOutput XML_PASSENGERQUERY_FAIL_2
    Transformation Compute DecideOnQuery
    Transformation Compute GetPassengerInformation
    Transformation Compute GetReservationsInformation
    Routing Label SinglePassenger
    Routing Label AllReservations
    Routing RouteToLabel RouteToLabel

    The RouteToLabel node dynamically routes the message according to the contents of the local environment that is associated with the message. The local environment contains the identity of one or more target Label nodes which are identified by their Label Name property (not the node name).

  3. Connect the nodes together as shown in the following table.
    For instructions, see Connecting message flow nodes in the IBM Integration Bus documentation.
    To check that you have connected the nodes together correctly, see the diagram in About the XML_PassengerQuery message flow.
    Node name Terminal Connect to
    XML_PASSENGERQUERY_IN Failure XML_PASSENGERQUERY_FAIL_1
    Out DecideOnQuery
    Catch XML_PASSENGERQUERY_FAIL_2
    DecideOnQuery Out RouteToLabel
    SinglePassenger Out GetPassengerInformation
    AllReservations Out GetReservationsInformation
    GetPassengerInformation Out XML_PASSENGERQUERY_OUT
    GetReservationsInformation Out XML_PASSENGERQUERY_OUT
  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 message flow node in the IBM Integration Bus documentation.
    Node name Page Property Value
    XML_PASSENGERQUERY_IN Basic Queue name XML_PASSENGERQUERY_IN
    (This value is the local queue from which the message flow takes the message.)
    Input Message Parsing Message domain XMLNSC : For XML messages (namespace aware, validation, low memory use)
    (This value tells the integration node to use the generic XML parser.)
    XML_PASSENGERQUERY_FAIL_1 Basic Queue name
    (You are not required to specify the name of the queue manager because the queue is defined on the same queue manager as the integration node.)
    XML_PASSENGERQUERY_FAIL
    (This value is the local queue on which the message flow puts the message if the processing fails.)
    XML_PASSENGERQUERY_FAIL_2 Basic Queue name
    (You are not required to specify the name of the queue manager because the queue is defined on the same queue manager as the integration node.)
    XML_PASSENGERQUERY_FAIL
    (This value is the local queue on which the message flow puts the message if the processing fails.)
    DecideOnQuery Basic ESQL module DecideOnQuery
    (This value 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.)
    Basic Compute mode LocalEnvironment and Message
    (This value causes the LocalEnvironment as well as the message to be passed to the RouteToLabel node after being modified.)
    RouteToLabel Basic Mode Route to First
    (This value causes the RouteToLabel node to start processing the list of destinations from the first item, at the top of the list.)
    SinglePassenger Basic Label name SinglePassenger
    (This value is the name of the Label node to which the message flow passes the message. The name must match the label name set in the Decide On The Query node. See the ESQL in the Decide_on_query module.)
    AllReservations Basic Label name AllReservations
    (This value is the name of the Label node to which the message flow passes the message. The name must match the label name set in the Decide On The Query node. See the ESQL in the Decide_on_query module.)
    GetPassengerInformation Basic Data source RESERVDB
    (This value is the database used by this node.)
    Basic ESQL module GetPassengerInformation
    (This value 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.)
    Basic Compute mode LocalEnvironment and Message
    (This value causes the LocalEnvironment, as well as the message, to be passed to the XML_PASSENGERQUERY_OUT node after being modified.)
    GetReservationsInformation Basic Data source RESERVDB
    (This value is the database used by this node.)
    Basic ESQL module GetReservationsInformation
    (This value 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.)
    Basic Compute mode LocalEnvironment and Message
    (This value causes the LocalEnvironment as well as the message to be passed to the XML_PASSENGERQUERY_OUT node after being modified.)
    XML_PASSENGERQUERY_OUT Basic Queue name
    (You are not required to specify the name of the queue manager because the queue is defined on the same queue manager as the integration node.)
    XML_PASSENGERQUERY_OUT
    (This value is the local queue on which the message flow puts 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 in the IBM Integration Bus documentation..
    -- ************************************************
    -- * ESQL for the XML_PassengerQuery message flow
    -- ************************************************
    
    CREATE COMPUTE MODULE DecideOnQuery
    	CREATE FUNCTION Main() RETURNS BOOLEAN
    	BEGIN
    		SET OutputRoot = InputRoot;
    		IF InputRoot.XMLNSC.PassengerQuery.ReservationNumber <> '' THEN
    			SET OutputLocalEnvironment.Destination.RouterList.DestinationData[1].labelname = 'SinglePassenger';
    		ELSE
    			SET OutputLocalEnvironment.Destination.RouterList.DestinationData[1].labelname = 'AllReservations';
    		END IF;
    		RETURN TRUE;
    	END;
    END MODULE;
    
    CREATE COMPUTE MODULE GetPassengerInformation
    	CREATE FUNCTION Main() RETURNS BOOLEAN
    	BEGIN
    		SET OutputRoot = InputRoot;
    		SET OutputRoot.XMLNSC.PassengerQuery = NULL;
    		-- populate the environment with passenger info from the database
    		SET Environment.Variables =
    			THE (SELECT T.* FROM Database.XMLPASSENGERTB AS T
    				WHERE T.RESERVATIONNO = InputRoot.XMLNSC.PassengerQuery.ReservationNumber);
    
    		-- populate the output message with info from the database query
    		CREATE FIELD OutputRoot.XMLNSC.PassengerInfoResponse.PassengerInfo;
    		DECLARE outpass REFERENCE TO OutputRoot.XMLNSC.PassengerInfoResponse.PassengerInfo;
    		SET outpass.ReservationNumber = Environment.Variables.RESERVATIONNO;
    		SET outpass.FirstName = Environment.Variables.FIRSTNAME;
    		SET outpass.LastName = Environment.Variables.LASTNAME;
    		SET outpass.FlightNumber = Environment.Variables.FLIGHTNO;
    		SET outpass.Date = Environment.Variables.FLIGHTDATE;
    		SET outpass.Class = Environment.Variables.CLASSTYPE;
    		RETURN TRUE;
    	END;
    END MODULE;
    
    CREATE COMPUTE MODULE GetReservationsInformation
    	CREATE FUNCTION Main() RETURNS BOOLEAN
    	BEGIN
    		SET OutputRoot = InputRoot;
    		SET OutputRoot.XMLNSC.PassengerQuery = NULL;
    		-- populate the environment with reservations info from the database
    		SET Environment.Variables.Reservation[] =
    			(SELECT T.* FROM Database.XMLPASSENGERTB AS T
    				WHERE T.FIRSTNAME = InputRoot.XMLNSC.PassengerQuery.FirstName 
    				AND T.LASTNAME = InputRoot.XMLNSC.PassengerQuery.LastName);
    
    		-- populate the output message with info from the database query
    		CREATE FIELD OutputRoot.XMLNSC.PassengerInfoResponse.ListOfReservations;
    		DECLARE outres REFERENCE TO OutputRoot.XMLNSC.PassengerInfoResponse.ListOfReservations;
    		DECLARE I INTEGER 1;
    		DECLARE J INTEGER CARDINALITY(Environment.Variables.*[]);
    		WHILE I <= J DO
    			SET outres.Reservation[I].FlightNumber = Environment.Variables.Reservation[I].FLIGHTNO;
    			SET outres.Reservation[I].Date = Environment.Variables.Reservation[I].FLIGHTDATE;
    			SET outres.Reservation[I].Class = Environment.Variables.Reservation[I].CLASSTYPE;
    			SET I = I + 1;
    		END WHILE;
    		RETURN TRUE;
    	END;
    END MODULE;
  6. Save the message flow.
You have created the XML_PassengerQuery message flow, which retrieves information about specific passengers who have reserved seats on a flight.

Back to Building the Airline Reservations sample