304 Using IBM WebSphere Message Broker as an ESB with WebSphere Process Server
MQOutput node
The MQOutput node queue manager is WBRK6_DEFAULT_QUEUE_MANAGER and the
output queue is OUTPUTQ, as shown in Figure 9-38.
Figure 9-38 MQOutput node
9.6.2 ErrorHandleFlow
The ErrorHandleFlow message flow performs a replay mechanism on the HTTP
request message for a certain amount of time with a specific delay between each
trial as shown in Figure 9-39.
Figure 9-39 ErrorHandleFlow
This flow contains the nodes that are described in the following sections.
Chapter 9. Scenario: Asynchronous callback 305
InitVar node
The InitVar Compute node saves the counter and the RequestURL (set by the
SRRetrieveITService node) to the SOAP Envelope header (Example 9-4).
Example 9-4 Saving the counter and request URL
CREATE COMPUTE MODULE ErrorHandleFlow_InitVar
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyEntireMessage();
--SET Environment.Counter = 0;
SET OutputRoot.XMLNS.soapenv:Envelope.soapenv:Header.Counter = 0;
SET OutputRoot.XMLNS.soapenv:Envelope.soapenv:Header.RequestURL =
InputLocalEnvironment.Destination.HTTP.RequestURL;
RETURN TRUE;
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
END MODULE;
Increment node
The Increment Compute node checks the number of retries. If the counter
exceeds the maximum number of retries, the output is propagated to a Compute
node that puts the message in the FAILUIREQ. If the counter does not exceed
the limit, it is incremented by one and the request timeout is set for the
TimeoutNotification node. See Example 9-5.
Example 9-5 Checking and incrementing the retry counter
CREATE COMPUTE MODULE ErrorHandleFlow_Increment
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyEntireMessage();
-- Remove the HTTP response header because its presence causes
problem in TimeOut control processing
SET OutputRoot.HTTPResponseHeader = NULL;
-- Check the number of retries
Important: The counter and the RequestURL are saved in the SOAP
Envelope header and not the Environment because the TimeoutNotification
node preserves the message and TimeoutRequest only.
306 Using IBM WebSphere Message Broker as an ESB with WebSphere Process Server
IF InputRoot.XMLNS.soapenv:Envelope.soapenv:Header.Counter <
MAXRetries THEN
SET OutputRoot.XMLNS.soapenv:Envelope.soapenv:Header.Counter =
CAST(InputRoot.XMLNS.soapenv:Envelope.soapenv:Header.Counter AS INTEGER
ENCODING InputRoot.Properties.Encoding) + 1;
ELSE
PROPAGATE TO TERMINAL 'out1';
RETURN FALSE;
END IF;
-- Create the delay interval that will be between each http
request
DECLARE DELAYINTERVAL INTERVAL;
SET DELAYINTERVAL = CAST(delay AS INTERVAL SECOND);
DECLARE DELAYTIMESTAMP TIMESTAMP CURRENT_TIMESTAMP +
DELAYINTERVAL;
-- Set the time out request that will be used by TimeOut
Notification
SET Environment.TimeoutRequest.Action = 'SET';
SET Environment.TimeoutRequest.Identifier = 'RETRY';
SET Environment.TimeoutRequest.StartDate = CAST(DELAYTIMESTAMP AS
DATE);
SET Environment.TimeoutRequest.StartTime = CAST(DELAYTIMESTAMP AS
TIME);
SET Environment.TimeoutRequest.Count = 1;
SET Environment.TimeoutRequest.IgnoreMissed = TRUE;
SET Environment.TimeoutRequest.AllowOverwrite = TRUE;
RETURN TRUE;
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
END MODULE;
Example 9-6 shows declaring the variables at the beginning of the file.
Example 9-6 Declaring the variables
DECLARE MAXRetries EXTERNAL CONSTANT INTEGER 2;
DECLARE delay EXTERNAL CONSTANT INTEGER 5;
Declare soapenv NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
Chapter 9. Scenario: Asynchronous callback 307
FAILUREQ node
The FAILUREQ MQOutput node (Figure 9-40) routes a message that reached its
maximum retries to the FAILUREQ queue and the flow ends. The support team
should monitor this queue and take the appropriate action.
Figure 9-40 FAILUREQ node
TimeoutControl node
The TimeoutControl node has the basic property settings that are shown in
Figure 9-41.
Figure 9-41 TimeoutControl node
Note: The values for the Unique Identifier and Request location fields are the
same as the values set in the Increment Compute node.
308 Using IBM WebSphere Message Broker as an ESB with WebSphere Process Server
TimeoutNotification node
The TimeoutNotification node is paired with the TimeoutControl node. It
processes timeout request messages that are sent by the TimeoutControl node
and propagates a copy of the messages to the next node in the message flow.
The TimeoutNotification node has the basic property settings that are shown in
Figure 9-42.
Figure 9-42 TimeoutNotification node
AddRequestURL Compute node
The AddRequestURL Compute node adds the request URL and MQMD header
back to the message (Example 9-7). The request URL is needed for the
HTTPRequest node that follows. The MQMD header is needed to put the
message on a queue. In the case of a failure, this is the FAILUREQ. In the case
of success, this is the OUTPUTQ.
Example 9-7 Adding the request URL and MQMD back to the message
CREATE COMPUTE MODULE ErrorHandleFlow_AddRequestURL
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyEntireMessage();
SET OutputLocalEnvironment.Destination.HTTP.RequestURL =
InputRoot.XMLNS.soapenv:Envelope.soapenv:Header.RequestURL;
SET Environment.MQMD = InputRoot.MQMD;
RETURN TRUE;
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
END MODULE;
The Compute mode is set to LocalEnvironment and Message because the
request URL is set in the LocalEnvironment (Figure 9-43 on page 309).
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.72.232