Skip to content

IRequestClient<T>

Namespace: MassTransit

The request client enables the request/response pattern, allowing a service to send a request and asynchronously await a response. Unlike fire-and-forget messaging, this interface keeps the control flow active until a response is received or a timeout occurs. It supports handling multiple response types, allowing the requester to distinctively handle success, failure, or other domain-specific outcomes.

public interface IRequestClient<TRequest>

TRequest
The request type

Create(TRequest, CancellationToken, RequestTimeout)

Section titled “Create(TRequest, CancellationToken, RequestTimeout)”

Create a request, returning a RequestHandle<TRequest>, which is then used to get responses, and ultimately send the request.

RequestHandle<TRequest> Create(TRequest message, CancellationToken cancellationToken, RequestTimeout timeout)

message TRequest
The request message

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

RequestHandle<TRequest>
A RequestHandle<TRequest> for the request

Create(Object, CancellationToken, RequestTimeout)

Section titled “Create(Object, CancellationToken, RequestTimeout)”

Create a request, returning a RequestHandle<TRequest>, which is then used to get responses, and ultimately send the request.

RequestHandle<TRequest> Create(object values, CancellationToken cancellationToken, RequestTimeout timeout)

values Object
The values to initialize the message

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

RequestHandle<TRequest>
A RequestHandle<TRequest> for the request

GetResponse<T>(TRequest, CancellationToken, RequestTimeout)

Section titled “GetResponse<T>(TRequest, CancellationToken, RequestTimeout)”

Create a request, and return a task for the specified response type

Task<Response<T>> GetResponse<T>(TRequest message, CancellationToken cancellationToken, RequestTimeout timeout)

T

message TRequest
The request message

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

Task<Response<T>>

GetResponse<T>(TRequest, RequestPipeConfiguratorCallback<TRequest>, CancellationToken, RequestTimeout)

Section titled “GetResponse<T>(TRequest, RequestPipeConfiguratorCallback<TRequest>, CancellationToken, RequestTimeout)”

Create a request, and return a task for the specified response type

Task<Response<T>> GetResponse<T>(TRequest message, RequestPipeConfiguratorCallback<TRequest> callback, CancellationToken cancellationToken, RequestTimeout timeout)

T

message TRequest
The request message

callback RequestPipeConfiguratorCallback<TRequest>

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

Task<Response<T>>

GetResponse<T>(Object, CancellationToken, RequestTimeout)

Section titled “GetResponse<T>(Object, CancellationToken, RequestTimeout)”

Create a request, and return a task for the specified response type

Task<Response<T>> GetResponse<T>(object values, CancellationToken cancellationToken, RequestTimeout timeout)

T

values Object
The values to initialize the message

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

Task<Response<T>>

GetResponse<T>(Object, RequestPipeConfiguratorCallback<TRequest>, CancellationToken, RequestTimeout)

Section titled “GetResponse<T>(Object, RequestPipeConfiguratorCallback<TRequest>, CancellationToken, RequestTimeout)”

Create a request, and return a task for the specified response type

Task<Response<T>> GetResponse<T>(object values, RequestPipeConfiguratorCallback<TRequest> callback, CancellationToken cancellationToken, RequestTimeout timeout)

T

values Object
The values to initialize the message

callback RequestPipeConfiguratorCallback<TRequest>

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

Task<Response<T>>

GetResponse<T1, T2>(TRequest, CancellationToken, RequestTimeout)

Section titled “GetResponse<T1, T2>(TRequest, CancellationToken, RequestTimeout)”

Create a request, and return a task for the specified response types

Task<Response<T1, T2>> GetResponse<T1, T2>(TRequest message, CancellationToken cancellationToken, RequestTimeout timeout)

T1
The first response type

T2
The second response type

message TRequest
The request message

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

Task<Response<T1, T2>>

GetResponse<T1, T2>(TRequest, RequestPipeConfiguratorCallback<TRequest>, CancellationToken, RequestTimeout)

Section titled “GetResponse<T1, T2>(TRequest, RequestPipeConfiguratorCallback<TRequest>, CancellationToken, RequestTimeout)”

Create a request, and return a task for the specified response types

Task<Response<T1, T2>> GetResponse<T1, T2>(TRequest message, RequestPipeConfiguratorCallback<TRequest> callback, CancellationToken cancellationToken, RequestTimeout timeout)

T1
The first response type

T2
The second response type

message TRequest
The request message

callback RequestPipeConfiguratorCallback<TRequest>

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

Task<Response<T1, T2>>

GetResponse<T1, T2>(Object, CancellationToken, RequestTimeout)

Section titled “GetResponse<T1, T2>(Object, CancellationToken, RequestTimeout)”

Create a request, and return a task for the specified response types

Task<Response<T1, T2>> GetResponse<T1, T2>(object values, CancellationToken cancellationToken, RequestTimeout timeout)

T1
The first response type

T2
The second response type

values Object
The values to initialize the message

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

Task<Response<T1, T2>>

GetResponse<T1, T2>(Object, RequestPipeConfiguratorCallback<TRequest>, CancellationToken, RequestTimeout)

Section titled “GetResponse<T1, T2>(Object, RequestPipeConfiguratorCallback<TRequest>, CancellationToken, RequestTimeout)”

Create a request, and return a task for the specified response types

Task<Response<T1, T2>> GetResponse<T1, T2>(object values, RequestPipeConfiguratorCallback<TRequest> callback, CancellationToken cancellationToken, RequestTimeout timeout)

T1
The first response type

T2
The second response type

values Object
The values to initialize the message

callback RequestPipeConfiguratorCallback<TRequest>

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

Task<Response<T1, T2>>

GetResponse<T1, T2, T3>(TRequest, CancellationToken, RequestTimeout)

Section titled “GetResponse<T1, T2, T3>(TRequest, CancellationToken, RequestTimeout)”

Create a request, and return a task for the specified response types

Task<Response<T1, T2, T3>> GetResponse<T1, T2, T3>(TRequest message, CancellationToken cancellationToken, RequestTimeout timeout)

T1
The first response type

T2
The second response type

T3

message TRequest
The request message

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

Task<Response<T1, T2, T3>>

GetResponse<T1, T2, T3>(TRequest, RequestPipeConfiguratorCallback<TRequest>, CancellationToken, RequestTimeout)

Section titled “GetResponse<T1, T2, T3>(TRequest, RequestPipeConfiguratorCallback<TRequest>, CancellationToken, RequestTimeout)”

Create a request, and return a task for the specified response types

Task<Response<T1, T2, T3>> GetResponse<T1, T2, T3>(TRequest message, RequestPipeConfiguratorCallback<TRequest> callback, CancellationToken cancellationToken, RequestTimeout timeout)

T1
The first response type

T2
The second response type

T3

message TRequest
The request message

callback RequestPipeConfiguratorCallback<TRequest>

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

Task<Response<T1, T2, T3>>

GetResponse<T1, T2, T3>(Object, CancellationToken, RequestTimeout)

Section titled “GetResponse<T1, T2, T3>(Object, CancellationToken, RequestTimeout)”

Create a request, and return a task for the specified response types

Task<Response<T1, T2, T3>> GetResponse<T1, T2, T3>(object values, CancellationToken cancellationToken, RequestTimeout timeout)

T1
The first response type

T2
The second response type

T3

values Object
The values to initialize the message

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

Task<Response<T1, T2, T3>>

GetResponse<T1, T2, T3>(Object, RequestPipeConfiguratorCallback<TRequest>, CancellationToken, RequestTimeout)

Section titled “GetResponse<T1, T2, T3>(Object, RequestPipeConfiguratorCallback<TRequest>, CancellationToken, RequestTimeout)”

Create a request, and return a task for the specified response types

Task<Response<T1, T2, T3>> GetResponse<T1, T2, T3>(object values, RequestPipeConfiguratorCallback<TRequest> callback, CancellationToken cancellationToken, RequestTimeout timeout)

T1
The first response type

T2
The second response type

T3

values Object
The values to initialize the message

callback RequestPipeConfiguratorCallback<TRequest>

cancellationToken CancellationToken
An optional cancellationToken to cancel the request

timeout RequestTimeout
An optional timeout, to automatically cancel the request after the specified timeout period

Task<Response<T1, T2, T3>>