Skip to content

In Process messaging

Ioan Crisan edited this page Oct 10, 2017 · 2 revisions

In-process messaging flow

In-Process Messaging

The DefaultMessageProcessor

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.

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 true is 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.

Clone this wiki locally