Share via


FSIA - Exception Handling and Notification to Monitoring tools when the CTS flow execution fails.

Typically when developing CTS flows and deploying in production environment, one of the concerns that comes along is how do we do exception handling of flows and monitor the flows, how do we notify the monitoring tools when flow is failed and then appropriate alarm can be raised by monitoring tools and teams. So below is one of the approaches that we have implemented currently in one of the implementations which is in production environments.

Here is the one of approach for exception handling.

For all the operators in the CTS flows wherever, there is chance that error can occur, add an error edge to the operator like shown below.

Then point the error edge operator to a common flow that will do the common exception handling and notification through flow runner. In the above case we point the error edge to a common flow through flow runner; the error edge flow runner will execute the common flow. This common flow will do the common exception handling. Below can be one of the sample exceptions handling flow. In the common flow you use the run code operator to do all the exception logging that can be down to various sources like event logs, FSIA log files etc.

Even after logging the exception challenge remains how this can be notified to various monitoring. Typically monitoring tools are port based so what they do is monitor certain set of ports on a particular server. So for notification you can create an exe which leverages certain port and ask the monitoring tools to monitor that port. So whenever exception is raised, you can terminate exe which is leveraging particular port. On the exe termination, monitoring tools do not receive the response and then they raise the red flag or an alert.

Instead of leveraging or building an exe, you can leverage IIS services as well, any ways IIS is pre-requisite for FSIA deployment. So you can have default web site with port (*.80) been stopped when the exception is been raised. Then you can have monitoring tools monitoring the default web site port. So in the exception handling flow you can execute the script which will stop the default web site or any web site configured in IIS for monitoring of flows. Below is sample, in the exception handling flow, in the run code operator, below code would launch as command prompt exe which would then execute the “StopFlowHostingEngineSite.bat” batch file which has script for stopping particular web site on an IIS.

 


 string command = @"D:\Temp\StopFlowHostingEngineSite.bat";<br>// create the ProcessStartInfo using "cmd" as the program to be run,<br>// and "/c " as the parameters.<br>// Incidentally, /c tells cmd that we want it to execute the command that follows,<br>// and then exit.<br>System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);<br>// The following commands are needed to redirect the standard output.<br>// This means that it will be redirected to the Process.StandardOutput StreamReader.<br>procStartInfo.RedirectStandardOutput = true;<br>procStartInfo.UseShellExecute = false;<br>// Do not create the black window.<br>procStartInfo.CreateNoWindow = false;<br>// Now we create a process, assign its ProcessStartInfo and start it<br>System.Diagnostics.Process proc = new System.Diagnostics.Process();<br>proc.StartInfo = procStartInfo;<br>proc.Start();<br>System.Threading.Thread.Sleep(5000);<br>proc.Kill();

StopFlowHostingEngineSite.bat will contain the following script

%windir%\system32\inetsrv\appcmd stop site /site.name:"Default Web Site"

Please note that this is one of the approaches for exception handling and notification to external monitoring tools, there can be other ways as well. Depending on you requirements, please make appropriate selection.