lesstriada.blogg.se

Masstransit handler
Masstransit handler









masstransit handler

The consumer’s job is to handle the message by invoking all the registered handlers. There, you can access the message using the Message property without casting it.Ī subscription will invoke a single consumer and give it an instance of the consume context. The typed handler will get an instance of MessageConsumeContext where T is the message type. It’s possible to handle each event type differently by using pattern matching: The context contains the payload (event or other message) in its Message property, which has the type object?.

masstransit handler

Instead of just getting the event, the handler will get an instance of the message context ( IMessageConsumeContext interface). The subscription will invoke all its event handlers at once for each event received. For specific implementations, you’d either use a built-in handler provided by a projection (like MongoDB projection), or the EventHandler abstract base class. Normally Eventuous uses either the BaseEventHandler abstract base class. The diagnostic name of the handler is used to distinguish logs in traces coming from a subscription per individual handler. You can configure the subscription to ignore failures and continue by setting ThrowIfError property of SubscriptionOptions to false. If the error is caused by a poison event, which can never be handled, it will keep failing in a loop. Such a failure will cause the subscription drop, and the subscription will resubscribe. If an event handler throws, the whole subscription will fail. An event handler must implement the IEventHandler interface, which has two members: It is especially relevant to keep a group of projections in sync, so they don’t produce inconsistent read models.Įach subscription service gets a list of event handlers. Event handlersĪs mentioned on the Concept page, one subscription might serve multiple event handlers, such as projections. You’d normally use the DI container to register subscriptions with all the necessary handlers (described below).

#MASSTRANSIT HANDLER REGISTRATION#

When using Eventuous subscription registration extensions for the DI container, the hosted service is registered automatically. Each registered subscription gets its own hosted service, so that each subscription can be managed independently. To host a subscription and manage its lifecycle, Eventuous has a hosted service called SubscriptionHostedService. If not provided, the default serializer is used.Įach provided subscription options type has more options, which depend on the subscription implementation details.

  • EventSerializer: an instance of the IEventSerializer interface, which is used to serialize and deserialize events.
  • masstransit handler

    When the subscription throws, it either NACKs the message, or stops the subscription depending on the implementation. ThrowOnError: a boolean indicating whether the subscription should throw an exception if an error occurs.SubscriptionId: a unique identifier for the subscription.The SubscriptionOptions base class has three properties: All the provided subscription options types inherit from the SubscriptionOptions base class. The base abstract class for subscriptions is the IMessageSubscription interface, but all the available subscriptions are based on the EventSubscription base class, which is a generic abstract class where its type parameter is the subscription options type.











    Masstransit handler