Dear Team,

How can we handle a Communication Exception in an action called by an OutSystems 'Timer' knowing that our module is a Web Application not Mobile?

We have a case where an action called by a timer (wake timer) inserts data into an external database. Sometimes, the connection times out. 

We need to rewake the timer iff the raised exception is due to a communication error such as network timed out or example "ORA-12537: Network Session".

Kindly advice the best approach to solving our problem.


Thank you in advance.

Lana


Hello Lana,

From the documentation: "In action flows starting in Timers you can only handle the raised exceptions by adding Exception Handler elements in your logic, otherwise, the execution flow is interrupted and the error is logged."

When you have an exception handler (like all exceptions, database exception, etc) in a Server Action, the Server Action can still return values through the Output Values. So, the first thing is that you can move the logic to a "second" server action that is called from the server action triggered by the timer and if an exception happens, you can return a value indicating an error and make the triggered action handle it (like calling it again, etc).

I'm not sure about what will happen if the action "times out", as I never tested it and don't know if the exception handler will catch it (don't think so). If this is the case, you would have to use an alternative method, like having your timer waking regularly and if the last operation failed (a 'success' should be stored if everything went well), you would trigger the action again, or not, otherwise. 

And if the problem is that you need to process a lot of records and sometimes the timeout happens, you may consider the approach of checking regularly if the timer is about to timeout and in that case, wake the timer again, stop the action and let it run again to continue with the process.

Cheers.

 Hello Eduardo,


Thank you for your prompt reply.

I'm handing the timer timeout and rewaking the timer if no error occurs. 


My problem is on the level of the connection to the remote database. Sometimes when the network is too busy the "network connection" is timing out and an exception is raised and caught by the "AllExceptions".

Is there any "Communication Exception" technique used in web application that resembles the "Communication Exception" that works only for mobile apps? 

How can I catch only the "Communication Exception" in a web application? 


Thank you in advance.

Lana

Hi Lana, 

Not that I know... 

You may try to recognize the error based on the message (if you're able to identify a pattern). 

And you may use a retry system where an exception will cause like more two tentatives before stopping. 

But this works better if you use the inner server action with the exception handler on it, set to not roll back, depending on your needs. 

Cheers 

Hello Eduardo,

I'm able to recognize the error based on the message.

How can I set that the number of attempts before stopping? Is it parametrized in the system?

Thank you,

Lana