Author |
Message
|
mqbrks |
Posted: Fri Jan 20, 2017 11:55 am Post subject: Exception Handler in ESQL - IMS Request |
|
|
Voyager
Joined: 17 Jan 2012 Posts: 75
|
Hi All,
I have a scenario where we need to process the records in a file. For each record a IMS request is to be sent and the ACKs are written back to file.
If the IMS request fails, a retry of 3 times is to be made. My logic is to write a handler in compute node. But the control doesn't come to the handler after propagate statement. Could someone please point what is wrong?
Code: |
DECLARE SUNRecordRef REFERENCE TO InputRoot.DFDL.GLBMGOSUN_IN_SUN.RECORD_IN_SUN[1];
-- Continue processing for each item in the array
WHILE LASTMOVE(SUNRecordRef) = TRUE DO
-- LL = lentgh of LL (2 bytes) + length of ZZ (2 bytes) + length of TransCode (8 bytes) + length of IMSData (first 10 chars of RECORD_IN_SUN)
SET OutputRoot.DFDL.IMSMessage.LL = 20;
-- Resrved
SET OutputRoot.DFDL.IMSMessage.ZZ = '0';
SET OutputRoot.DFDL.IMSMessage.TRANCODE = SUBSTRING(SUNRecordRef FROM 11 FOR 8);
SET OutputRoot.DFDL.IMSMessage.IMSDATA = SUBSTRING(SUNRecordRef FROM 1 FOR 10);
SET totalProcessedCount = totalProcessedCount + 1;
SET Environment.Variables.TotalProcessedCount = totalProcessedCount;
SET Environment.Variables.TransCode = SUBSTRING(SUNRecordRef FROM 11 FOR 8);
SET Environment.Variables.SUN = SUBSTRING(SUNRecordRef FROM 1 FOR 10);
PROPAGATE TO TERMINAL 'out';
RETURN FALSE;
DECLARE retryCount INTEGER 0;
WHILE retryCount <=3 DO
DECLARE CONTINUE HANDLER FOR SQLSTATE LIKE '%'
BEGIN
---If error occurs while propagating msg to IMS Server , retry for 3 times
SET retryCount = retryCount + 1;
-- LL = lentgh of LL (2 bytes) + length of ZZ (2 bytes) + length of TransCode (8 bytes) + length of IMSData (first 10 chars of RECORD_IN_SUN)
SET OutputRoot.DFDL.IMSMessage.LL = 20;
-- Resrved
SET OutputRoot.DFDL.IMSMessage.ZZ = '0';
SET OutputRoot.DFDL.IMSMessage.TRANCODE = SUBSTRING(SUNRecordRef FROM 11 FOR 8);
SET OutputRoot.DFDL.IMSMessage.IMSDATA = SUBSTRING(SUNRecordRef FROM 1 FOR 10);
PROPAGATE TO TERMINAL 'out';
END;
END WHILE;
-- Move the dynamic reference to the next item in the array
MOVE SUNRecordRef NEXTSIBLING;
END WHILE; |
Also is this logic good?? One of my friend says to have a subflow (for retry) after the IMS request and route back the request to the IN terminal of the IMS request node. I feel using handler reduces the number of nodes.
Your inputs are really appreciated. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Jan 20, 2017 12:39 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
RETURN FALSE ends the compute node. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
Vitor |
Posted: Fri Jan 20, 2017 12:40 pm Post subject: Re: Exception Handler in ESQL - IMS Request |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqbrks wrote: |
But the control doesn't come to the handler after propagate statement. Could someone please point what is wrong? |
Nothing - functioning as designed. The PROPOGATE statement sends a new copy of the tree down the flow; it's not a procedure call.
mqbrks wrote: |
Also is this logic good?? |
No.
mqbrks wrote: |
One of my friend says to have a subflow (for retry) after the IMS request and route back the request to the IN terminal of the IMS request node. |
That sucks too.
mqbrks wrote: |
I feel using handler reduces the number of nodes. |
The only reason to worry about the number of nodes in a flow is if you have a stupid number of them (like node labels are so crammed together on the Toolkit canvas and/or you're using both of the scroll bars to see the entire flow) or you have a really, really tight SLA and you're trying to squeeze microseconds out of the flow.
mqbrks wrote: |
Your inputs are really appreciated. |
I would push the retry logic into a flow (not a subflow) headed by a Timer node, adding logic to count how many times the flows been retried - once you hit 3 the flow cancels the timer and does whatever you do for a persistent IMS error. This method has the additional advantage that you can allow a little time between retries rather than just banging away at IMS 4 times in a row. It's more likely that a transient problem will not go away between the original attempt & the 3rd immediate retry, but might do if you wait 5 seconds between attempts. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqbrks |
Posted: Fri Jan 20, 2017 2:02 pm Post subject: Re: Exception Handler in ESQL - IMS Request |
|
|
Voyager
Joined: 17 Jan 2012 Posts: 75
|
Quote: |
I would push the retry logic into a flow (not a subflow) headed by a Timer node, adding logic to count how many times the flows been retried - once you hit 3 the flow cancels the timer and does whatever you do for a persistent IMS error. This method has the additional advantage that you can allow a little time between retries rather than just banging away at IMS 4 times in a row. It's more likely that a transient problem will not go away between the original attempt & the 3rd immediate retry, but might do if you wait 5 seconds between attempts. |
Thank you jeff and vitor for your inputs!!
But the problem here is we need to accumulate all the ACKs and process remaining records in the file. When we use timer flow it is disconnected from the main file process right? [/quote] |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Jan 20, 2017 10:33 pm Post subject: Re: Exception Handler in ESQL - IMS Request |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
mqbrks wrote: |
But the problem here is we need to accumulate all the ACKs and process remaining records in the file. When we use timer flow it is disconnected from the main file process right? |
Yes. A timer node event starts a new process thread. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jan 23, 2017 5:05 am Post subject: Re: Exception Handler in ESQL - IMS Request |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqbrks wrote: |
But the problem here is we need to accumulate all the ACKs and process remaining records in the file. When we use timer flow it is disconnected from the main file process right? |
Yes, and why is that a problem? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|