Class ProtoMessageClient
The test-side messaging API over the configured broker. Publishes and awaits are traced as
messaging.publish and messaging.await operations with the payload as a section, and
recorded as observations for the trace and for a collector a suite registers; the package itself
ships no collector and aggregates no destinations.
public sealed class ProtoMessageClient
- Inheritance
-
ProtoMessageClient
- Inherited Members
- Extension Methods
Methods
AwaitAsync(string, Func<ProtoMessage, bool>, TimeSpan?, CancellationToken)
Waits for the first message on destination matching predicate
within the timeout (the configured default when none is given). Failing to arrive is a test
failure, not a sleep. An exchange destination waits on a tap prepared for it; a queue destination
(queue:{name}, see Queue(string)) waits on the queue itself, and an
adapter whose broker has no queues fails naming the transport. A destination whose tap could not
be declared during setup fails the await with the adapter's named error instead of timing out.
public Task<ProtoMessage> AwaitAsync(string destination, Func<ProtoMessage, bool> predicate, TimeSpan? timeout = null, CancellationToken cancellationToken = default)
Parameters
destinationstringpredicateFunc<ProtoMessage, bool>timeoutTimeSpan?cancellationTokenCancellationToken
Returns
AwaitAsync(string, string, Func<ProtoMessage, bool>, TimeSpan?, CancellationToken)
Waits for the first message on destination matching predicate
that the transport carried under routingKey. On RabbitMQ the tap binds the
routing key as well as the exchange, so a direct exchange delivers it; a timeout names both the
destination and the routing key.
public Task<ProtoMessage> AwaitAsync(string destination, string routingKey, Func<ProtoMessage, bool> predicate, TimeSpan? timeout = null, CancellationToken cancellationToken = default)
Parameters
destinationstringroutingKeystringpredicateFunc<ProtoMessage, bool>timeoutTimeSpan?cancellationTokenCancellationToken
Returns
PublishAsync(string, string?, IReadOnlyDictionary<string, string?>?, string?, CancellationToken)
Publishes one message to the exchange named by destination, optionally with
headers and a content type. A queue destination (Queue(string)) is
consumed, not published to, and fails naming the queue.
public Task PublishAsync(string destination, string? payload = null, IReadOnlyDictionary<string, string?>? headers = null, string? contentType = null, CancellationToken cancellationToken = default)
Parameters
destinationstringpayloadstringheadersIReadOnlyDictionary<string, string>contentTypestringcancellationTokenCancellationToken
Returns
PublishAsync(string, string, string?, IReadOnlyDictionary<string, string?>?, string?, CancellationToken)
Publishes one message to destination under routingKey, which
the RabbitMQ adapter sends as the AMQP routing key and records on consumed messages. The payload
stays a required argument so this overload does not compete with the payload-only one. A transport
that addresses by something other than a routing key (MassTransit's contract types) fails the
publish naming the destination instead of dropping the key.
public Task PublishAsync(string destination, string routingKey, string? payload, IReadOnlyDictionary<string, string?>? headers = null, string? contentType = null, CancellationToken cancellationToken = default)
Parameters
destinationstringroutingKeystringpayloadstringheadersIReadOnlyDictionary<string, string>contentTypestringcancellationTokenCancellationToken