Skip to content

Multicast Request Response Take First

David Gardiner edited this page Oct 27, 2017 · 3 revisions

Why

This is a variaton on the Multicast Request Response example. Instead of the scenario where we want to collect all responses we may only care about latency and the time to the first response.

The Pattern

In this Multicast Request Response we only take the first response and discard the rest.

How

To make the request on the bus we implement the same IBusRequest. This might look like:

public class FraudulentCardRequest : IBusRequest<FraudulentCardRequest, IsThisDodgyResponse>
{
	

}

And then we make a MulticastRequest on the bus and call First

var response = (await bus.MulticastRequest(request)).First();

Handling it

To implement the handler to fulfil this request we implement IHandleRequest handler class as we would for a simple Request Response.