eren arslan
eren arslan

Reputation: 207

MediatR multiple RequestHandlers

I have a request which contains some information about order.

I have Rule sets for orders. When I send this request It should handle by all rule handlers and return results. All handlers get same request object.

Can I send register multiple request handlers for mediatr ?

(I can't use notifications. They are fire forget. And I need return result)

Upvotes: 2

Views: 13038

Answers (1)

galdin
galdin

Reputation: 14034

Can I send register multiple request handlers for mediatr?

No. From the docs:

MediatR has two kinds of messages it dispatches:

  1. Request/response messages, dispatched to a single handler
  2. Notification messages, dispatched to multiple handlers

This is by design.

Send = Tell someone a message (command)
Publish = Tell the world something happened (event)

Since mediatr works in-process, Requests (Send()) can also return a response.
And again, since mediatr works in-process, Publish() is not fire-and-forget (not by default at least).

Upvotes: 5

Related Questions