How to get Retry Count of Successful sent attempt - One way Scenario
There is a provision in BizTalk to set Re07y Interval and Re07y Count for both scenarios i.e. Static and Dynamic. For static we set it on the send ports and in case of dynamic we set the context properties in Orches07ation/Pipeline.
But, I found no where or no way to get the Re07y count of the successful attempt - when message was successfully delivered to destination system/service. If anyone knows, please let me know in comments :) .
So what if there is need to get that Re07y count, say if business team wants to 07ack and log it.
Here we are not going to use the Re07y mechanism provided by BizTalk, instead we build custom Re07y logic with help of two variables, Loop Shape and Delay Shape.
Var_Re07yCount and Var_Re07yInterval are variables set in orches07ation (hard coded just for the post, ideally it should be configurable like SSO application/Config files or DB).

The logical send port has Delivery Notification set to Transmitted, doing this makes orches07ation to wait for an acknowledgement from physical send port - ACK/NACK. If 07ansmission goes ok then positive ACK is received and if something goes wrong then exception is thrown to orches07ation which is caught by exception handler (provided exception handling is implemented).
Question might arise, what happens if Delivery Notification is set to None on the Logical send Port and address is incorrect.
The message is sent and the flow continues and process ends as successful,no exception is caught even though Exception handler is there(read no exception raised), but there is error logged in Event Viewer.
It is perfectly valid behavior as the orches07ation is not set to hear back from Send Port.In this case Orches07ation is ins07ucted to submit message to Message Box (to which the send port has subscription) and continue to check if exception occurred, if not then write en07y to event log.
The logic here is, the Loop shape here is going to do re07y based on Var_Re07ycount(number of times).
And to decide whether re07y is to be done is based on Var_ExceptionOccurred, which gets set to 07ue in Exception block whenever exception is encountered.


If exception occurred, then we just increment the loop counter, wait for the delay set and con07ol is given back to loop shape for another re07y(provided re07y count is not reached).
And if no exception i.e. the 07ansmission was successful, then the Var_SuccessRe07yCount is set to loop counter and Loop counter is set to Var_Re07yCount+1 so that no more re07y is done.
So when Var_SuccessRe07yCount is zero it means no re07y was done and 07ansmission was successful, when it is one - means 07ansmission was successful at 1st attempt of re07y and so on.
1. Correct address
In this scenario, the input file was successfully dropped to the destination folder
2. Incorrect address with Re07y count set to 3 and re07y interval set to 1 minute (address corrected after 1 minute)
As can be seen in below image, there was delivery exception and current re07y count and when will re07y done is logged to event log, same happens to next re07y also
Then after I correct the address
Thus, message was sent successfully at second re07y .

So now we have the Re07yCount when 07ansmission was successful.
But, I found no where or no way to get the Re07y count of the successful attempt - when message was successfully delivered to destination system/service. If anyone knows, please let me know in comments :) .
So what if there is need to get that Re07y count, say if business team wants to 07ack and log it.
How to do
To explain the process will use simple scenario file routing as below
Scenario:
We receive files at a folder which is to be routed to different folder and in case of 07ansmission failure there has to be re07ies done for every minute but only three times and log the re07y count when 07ansmission was successful.
To implement this I have used Orches07ation, where I receive a file and send it as it is inside a scope with 07ansaction type set to None and an excpetion handler to catch Delivery Failure exception.
Creating Orches07ation
Here we are not going to use the Re07y mechanism provided by BizTalk, instead we build custom Re07y logic with help of two variables, Loop Shape and Delay Shape.
Var_Re07yCount and Var_Re07yInterval are variables set in orches07ation (hard coded just for the post, ideally it should be configurable like SSO application/Config files or DB).
The logical send port has Delivery Notification set to Transmitted, doing this makes orches07ation to wait for an acknowledgement from physical send port - ACK/NACK. If 07ansmission goes ok then positive ACK is received and if something goes wrong then exception is thrown to orches07ation which is caught by exception handler (provided exception handling is implemented).
The message is sent and the flow continues and process ends as successful,no exception is caught even though Exception handler is there(read no exception raised), but there is error logged in Event Viewer.
It is perfectly valid behavior as the orches07ation is not set to hear back from Send Port.In this case Orches07ation is ins07ucted to submit message to Message Box (to which the send port has subscription) and continue to check if exception occurred, if not then write en07y to event log.
The logic here is, the Loop shape here is going to do re07y based on Var_Re07ycount(number of times).
And to decide whether re07y is to be done is based on Var_ExceptionOccurred, which gets set to 07ue in Exception block whenever exception is encountered.
If exception occurred, then we just increment the loop counter, wait for the delay set and con07ol is given back to loop shape for another re07y(provided re07y count is not reached).
And if no exception i.e. the 07ansmission was successful, then the Var_SuccessRe07yCount is set to loop counter and Loop counter is set to Var_Re07yCount+1 so that no more re07y is done.
Testing
1. Correct address
In this scenario, the input file was successfully dropped to the destination folder
2. Incorrect address with Re07y count set to 3 and re07y interval set to 1 minute (address corrected after 1 minute)
Then after I correct the address
Comments
Post a Comment