Knowledgebase
How to skip execution of a "Current Time" based event trigger if there is still a current execution running
Posted by John Villanueva on 24 July 2018 01:24 AM

The problem

There may be times when you would want a trigger to skip/abort execution if a previous execution of the same trigger is still running. Here's a sample scenario where this particular capability might come in handy:

Let's say you have a time-based trigger (a trigger that uses the 'Current Time' event type) set to run daily which sometimes transfers an exceptionally large number of files. Sometimes, the number of files gets so large that the trigger has to continue running the following day. Because the trigger is scheduled to run daily, it will have to run again the following day. 

Unfortunately, that new execution will cause an overlap with the previous one that's already executing. In effect, two executions of the same trigger will be running simultaneously. This situation will cause a race condition that can lead to conflicts (e.g. when the two triggers compete for the same files) that will eventually cause one or both trigger executions to fail. 

Obviously, you need a way to stop the second trigger execution if the same trigger is still running.

 

Note: While we already have the "Run trigger in single instance mode" feature in MFT Server v11, that option will only queue up the trigger for execution after the current execution is done. The issue we're talking about here calls for a solution to abandon/skip the execution altogether if a current one is still running. 

The Solution

The way to address this issue would be to create a dummy flag file and then modify the trigger's Trigger Condition to check for the existence of this file. You need to set the condition expression so that the trigger will only execute if the dummy flag file is not present. So, for example, if you want the trigger to execute at midnight, the condition will be something like this:

Hour = 0 AND Minute = 0 AND GetFileExists("/path/to/dummy_flag_file") = FALSE

The above condition will allow the trigger to execute at midnight but only if the file "/path/to/dummy_flag_file" does not exist.

For this to work, you need to add an "Append File" action before your main (transfer?) action to create the dummy flag file that will signify that it is now running. After that, you need to add a "Delete File" action after it (your main action) to signify it is done running.

You also need to handle the situation where the main action will fail for some reason, which would in turn prevent the "Delete File" action from running. For this, you will have to create an "error handler" trigger that uses the "Trigger Error" event type. This trigger will take care of deleting the dummy flag file in cases where the main action action fails. For this to work, you need to have a way to pass the path of the dummy flag file of the trigger that failed. For example, if your main action is a "Trading Partner Regex File Upload" action then you can use the "Trigger Error Message" field under "Advanced" on the and set the path of the dummy flag file there.

Related content:

Capturing & Responding to Trigger Errors in JSCAPE MFT Server

 

(0 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below. This is required to prevent automated registrations and form submissions.

Help Desk Software by Kayako fusion