Chapter 5. Scenario: Message splitting and routing 107
SET suppID = forRef.Supplier.SupplierID;
(2)
SET ileRef.Variables.destQ[] = (SELECT R.DESTINATION_QUEUE
(3)
FROM Database.BKR_FLOW_DATA.ROUTING AS R
WHERE R.SUPPLIER_ID = suppID);
CASE -- Let's see if we have any errors/missing values after our attempt
-- to retrieve routing details from the database
WHEN SQLCODE <> 0 THEN
(5)
-- There is a database access problem.
--Let's report it on the relevant queue
SET oleRef.Destination.MQDestinationList.DestinationData[1].queueName
= 'HOLDINGQ_MSGS_WITH_DB_ACCESS_ISSUES';
CREATE LASTCHILD OF OutputRoot DOMAIN('XML');
SET OutputRoot.XML.Message.Summary =
'Database problem encountered when attempting to '||
'retrieve routing data for an instance of a '||
'ProcessOrdersRequest message';
SET OutputRoot.XML.Message.Details.Detail[1] =
'SQLSTATE is: ' || CAST(SQLSTATE AS CHAR);
SET OutputRoot.XML.Message.Details.Detail[2] =
'SQLCODE is: ' || CAST(SQLCODE AS CHAR);
SET OutputRoot.XML.Message.Details.Detail[3] =
'SQLERRORTEXT is: ' || CAST(SQLERRORTEXT AS CHAR);
SET OutputRoot.XML.Message.Details.Detail[4] =
'SQLNATIVEERROR is: ' || CAST(SQLNATIVEERROR AS CHAR);
WHEN NOT EXISTS(ileRef.Variables.destQ[]) THEN
(6)
-- No routing entry found for supplier. Send a message
-- to the 'invalid destination' queue
SET oleRef.Destination.MQDestinationList.DestinationData[1].queueName =
'HOLDINGQ_MSGS_WITH_INVALID_DESTINATIONS';
CREATE LASTCHILD OF OutputRoot DOMAIN('XML');
SET OutputRoot.XML.Message.Summary =
'No routing entry exists for the following instance of a
ProcessOrdersRequest message';
ELSE
(4)
-- All ok. Let's setup the destination queue using the routing
-- details retrieved from the database
SET oleRef.Destination.MQDestinationList.DestinationData[1].queueName =
TRIM(ileRef.Variables.destQ[1].DESTINATION_QUEUE);
END CASE;