-
Notifications
You must be signed in to change notification settings - Fork 9
In Process messaging

Kephas provides the DefaultMessageProcessor class, a low override priority message processor. It provides a basic, overridable functionality for processing messages, which should be enough for most cases.
- It aggregates message handler selectors and calls them to provide a list of message handlers to process a particular message, in their processing priority order.
- It aggregates processing filters and calls them before and after each handler's
ProcessAsynccall.
Note that the message processor is an in-process service. However, if the handlers themselves go beyond the process boundary it is their sole responsibility and, at the same time, freedom.
The flow of the ProcessAsync implementation is as follows:
- Resolve the processing filters, ordered by their processing priority.
- Resolve the handlers, as provided by the handler selectors called in their processing priority order.
- Question the selectors in the indicated order whether they can provide handlers for the message.
- The first selector answering with
trueis delegated to provide the handlers, the rest are ignored.
- Call each handler to process the message, awaiting for their response.
- Before calling the handler, the ordered filters are invoked.
- After calling the handler, the filters are invoked in the inverse order.
- Returns the response of the last called handler.
Note: if the handler throws an exception, the processing filters are called in the after method. with the exception information set in the context. However, if a filter throws an exception during the processing, it interrupts the flow and the exception is thrown to the caller. This is by design, so that, for example, authorization filters are able to interrupt the processing flow.