With service error handling control, you configure events and corresponding actions to take on sessions, tasks, and service instances when a service is in a specific state of its lifecycle. This feature also enables you to configure timeouts for all methods within the service and actions to take when a timeout occurs.
For example, in the service onInvoke() call, you could configure that if the method exits, the system is to restart the service.
The following table lists API methods that can be used in service code, possible events that can be configured for each method, and possible actions that can be taken on workload (session or task) and on service instances upon trigger of the event.
The following actions are possible on workload (sessions and tasks). Note that the possible combination of actions varies according to the method.
The following actions are possible on the service instance. Note that the possible combination of actions varies according to the method.
The control code is an integer returned either normally through the return of the method, or returned when a fatal or failure exception occurs. You can configure specific numbers to trigger actions in all methods except Register() and DestroyService().
The default value for control codes is 0. So if you do not explicitly set a control code in your service, then return is considered to have a control code of 0. Symphony executes the behavior defined for control code ="0" for the service event that occurs.
If you want, for example, to sometimes restart the service instance and sometimes not, then use any number other than 0 for your control code. For example, if you want to restart the service instance on every 10th invoke, indicate a code of 1. A code of 0 indicates the default action.
<Control><Method name="Register" ><Timeout duration="60" actionOnSI="blockHost"/><Exit actionOnSI="blockHost"/></Method><Method name="CreateService" ><Timeout duration="0" actionOnSI="blockHost"/><Exit actionOnSI="blockHost"/><Return controlCode="0" actionOnSI="keepAlive"/><Exception type="failure" controlCode="0" actionOnSI="blockHost"/><Exception type="fatal" controlCode="0" actionOnSI="blockHost"/></Method><Method name="SessionEnter" ><Timeout duration="0" actionOnSI="blockHost" actionOnWorkload="retry"/><Exit actionOnSI="blockHost" actionOnWorkload="retry"/><Return controlCode="0" actionOnSI="keepAlive" actionOnWorkload="succeed"/><Exception type="failure" controlCode="0" actionOnSI="keepAlive" actionOnWorkload="retry"/><Exception type="fatal" controlCode="0" actionOnSI="keepAlive" actionOnWorkload="fail"/></Method><Method name="SessionUpdate" ><Timeout duration="0" actionOnSI="blockHost" actionOnWorkload="retry"/><Exit actionOnSI="blockHost" actionOnWorkload="retry"/><Return controlCode="0" actionOnSI="keepAlive" actionOnWorkload="succeed"/><Exception type="failure" controlCode="0" actionOnSI="keepAlive" actionOnWorkload="retry"/><Exception type="fatal" controlCode="0" actionOnSI="keepAlive" actionOnWorkload="fail"/></Method><Method name="Invoke" ><Timeout duration="0" actionOnSI="restartService" actionOnWorkload="retry"/><Exit actionOnSI=" restartService" actionOnWorkload="retry"/><Return controlCode="0" actionOnSI="keepAlive" actionOnWorkload="succeed"/><Exception type="failure" controlCode="0" actionOnSI="keepAlive" actionOnWorkload="retry"/><Exception type="fatal" controlCode="0" actionOnSI="keepAlive" actionOnWorkload="fail"/></Method><Method name="SessionLeave" ><Timeout duration="0" actionOnSI="restartService"/><Exit actionOnSI=" restartService"/><Return controlCode="0" actionOnSI="keepAlive" customizedDebugAction="none"/><Exception type="failure" controlCode="0" actionOnSI="keepAlive"/><Exception type="fatal" controlCode="0" actionOnSI="keepAlive"/></Method><Method name="DestroyService" ><Timeout duration="15"/></Method></Control>
Configure a timeout value for the onInvoke() method and specify to fail the workload when the method times out.
It is possible that in your environment you do not want hosts to be blocked under any circumstances. As a best practice, setting the system to not block hosts ever is not recommended. This is because if a service fails on a host, if the host is not blocked, the system may end up in an endless loop attempting to start the service on the same host on which it is always failing and continuously writing errors to the log files. In a very short time, your log files grow very large and take up too much disk space on your machine.
However, should you need to do this in your environment, you can accomplish this by setting all actionOnSI parameters to not block the host:
<SIM startUpTimeout="60" blockHostOnTimeout="false" blockHostOnVersionMismatch="false">…</SIM><Control><Method name="Register" ><Timeout duration="60" actionOnSI="restartService"/><Exit actionOnSI="restartService"/></Method><Method name="CreateService" ><Timeout duration="0" actionOnSI="restartService"/><Exit actionOnSI="restartService"/><Return controlCode="0" actionOnSI="keepAlive"/><Exception type="failure" controlCode="0" actionOnSI="restartService"/><Exception type="fatal" controlCode="0" actionOnSI="restartService"/></Method><Method name="SessionEnter" ><Timeout duration="0" actionOnSI="restartService" actionOnWorkload="retry"/><Exit actionOnSI="restartService" actionOnWorkload="retry"/><Return controlCode="0" actionOnSI="keepAlive" actionOnWorkload="succeed"/><Exception type="failure" controlCode="0" actionOnSI="keepAlive" actionOnWorkload="retry"/><Exception type="fatal" controlCode="0" actionOnSI="keepAlive" actionOnWorkload="fail"/></Method><Method name="SessionUpdate" ><Timeout duration="0" actionOnSI="restartService" actionOnWorkload="retry"/><Exit actionOnSI="restartService" actionOnWorkload="retry"/><Return controlCode="0" actionOnSI="keepAlive" actionOnWorkload="succeed"/><Exception type="failure" controlCode="0" actionOnSI="keepAlive" actionOnWorkload="retry"/><Exception type="fatal" controlCode="0" actionOnSI="keepAlive" actionOnWorkload="fail"/></Method><Method name="Invoke" ><Timeout duration="0" actionOnSI="restartService" actionOnWorkload="retry"/><Exit actionOnSI="restartService" actionOnWorkload="retry"/><Return controlCode="0" actionOnSI="keepAlive" actionOnWorkload="succeed"/><Exception type="failure" controlCode="0" actionOnSI="keepAlive" actionOnWorkload="retry"/><Exception type="fatal" controlCode="0" actionOnSI="keepAlive" actionOnWorkload="fail"/></Method><Method name="SessionLeave" ><Timeout duration="0" actionOnSI="restartService"/><Exit actionOnSI=" restartService"/><Return controlCode="0" actionOnSI="keepAlive"/><Exception type="failure" controlCode="0" actionOnSI="keepAlive"/><Exception type="fatal" controlCode="0" actionOnSI="keepAlive"/></Method><Method name="DestroyService" ><Timeout duration="15"/></Method></Control>