-
Notifications
You must be signed in to change notification settings - Fork 4
Error handling
Simon Taddiken edited this page Oct 17, 2016
·
2 revisions
When a scheduled method throws an exception it will be handed to the default ExceptionHandler
. The default implemenation simply logs the stack trace with some additional information about the scheduled method.
You can specify a custom ExceptionHanlder
on a scheduled method using @OnError
:
@Scheduled
@SimpleTrigger(5000)
@OnError(MyCustomExceptionHandler.class)
public void scheduledMethod() {
}
Please note that the exception handler is eagerly instantiated by the framework before scheduling the method the first time. Thus you can't inject ScheduledScope
or ExecutionScope
types into your handler. However, the handler's onException
method will be called while the ScheduledContext
is still active. This means you can inject a Provider
or a scoped proxy of your class and access it within onException
.