Class MessageCatcher

java.lang.Object
eu.bandm.tools.message.SingleSender<Message>
eu.bandm.tools.message.MessageCatcher
All Implemented Interfaces:
Runnable

public abstract class MessageCatcher extends SingleSender<Message> implements Runnable
Executes payload code and sends the first exception caught to its given message drain.

The execution ends with the programmed end of the payload code, or when a exception is caught. Then execution can be restarted.

The payload code can be defined

  1. by explicitly defining payload() in a derived class, or
  2. by using the factory method tryCatch(java.lang.Runnable, eu.bandm.tools.message.MessageReceiver<eu.bandm.tools.message.Message>) with a Runnable

In either case, run() starts the controlled execution.

A caught MessageException is unwrapped and sent directly to the given MessageReceiver. All other exceptions are wrapped into a SimpleMessage of kind failure.

Errors are not caught, only Exceptions.