-
Notifications
You must be signed in to change notification settings - Fork 23
Requestresponse
derekgreer edited this page Sep 13, 2012
·
7 revisions
RabbitBus supports the Request/Response message pattern (a.k.a. Remote Procedure Calls) through an overload of the IBus.Publish()
method which accepts a response delegate. For example, the following publishes a RequestMessage
message and provides a delegate for handling a resulting ResponseMessage
message using an existing instance of Bus
:
bus.Publish<RequestMessage, ResponseMessage>(new RequestMessage(), messageContext => { /* handle ResponseMessage */ });
By default, RabbitBus will wait indefinitely for the response message. To instruct RabbitBus to only wait for a specified time, an overload is provided which accepts a TimeSpan
parameter used as the response subscription timeout value. The following example waits for response messages for 5 minutes:
bus.Publish<RequestMessage, ResponseMessage>(new RequestMessage(),
messageContext => { /* handle ResponseMessage */ },
TimeSpan.FromMinutes(5));