Interface IInMemoryMqttBroker
A mocked MQTT broker where the messages are just exchanged in-memory. Note that it isn't obviously possible to accurately replicate the message broker behavior and this implementation is just intended for testing purposes.
Namespace: Silverback.Messaging.Broker.Mqtt.Mocks
Assembly: Silverback.Integration.MQTT.Testing.dll
Syntax
public interface IInMemoryMqttBroker
Methods
| Improve this doc View sourceConnect(MqttClientOptions, MockedMqttClient)
Connects the specified client.
Declaration
void Connect(MqttClientOptions clientOptions, MockedMqttClient mockedMqttClient)
Parameters
Type | Name | Description |
---|---|---|
MQTTnet.Client.MqttClientOptions | clientOptions | The client options. |
MockedMqttClient | mockedMqttClient | The MockedMqttClient. |
Disconnect(String)
Disconnects the specified client.
Declaration
void Disconnect(string clientId)
Parameters
Type | Name | Description |
---|---|---|
System.String | clientId | The client identifier. |
GetClientSession(String)
Gets the IClientSession of the specified client.
Declaration
IClientSession GetClientSession(string clientId)
Parameters
Type | Name | Description |
---|---|---|
System.String | clientId | The client id. |
Returns
Type | Description |
---|---|
IClientSession | The IClientSession. |
GetMessages(String)
Gets the messages that have been published to the specified topic.
Declaration
IReadOnlyList<MqttApplicationMessage> GetMessages(string topic)
Parameters
Type | Name | Description |
---|---|---|
System.String | topic | The name of the topic. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<MQTTnet.MqttApplicationMessage> | The messages published to the topic. |
PublishAsync(String, MqttApplicationMessage, MqttClientOptions)
Publishes a message.
Declaration
Task PublishAsync(string clientId, MqttApplicationMessage message, MqttClientOptions clientOptions)
Parameters
Type | Name | Description |
---|---|---|
System.String | clientId | The client identifier. |
MQTTnet.MqttApplicationMessage | message | The MQTTnet.MqttApplicationMessage to be published. |
MQTTnet.Client.MqttClientOptions | clientOptions | The MQTTnet.Client.MqttClientOptions of the producing MQTTnet.Client.MqttClient. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |
Subscribe(String, IReadOnlyCollection<String>)
Subscribes the specified client to the specified topics.
Declaration
void Subscribe(string clientId, IReadOnlyCollection<string> topics)
Parameters
Type | Name | Description |
---|---|---|
System.String | clientId | The client identifier. |
System.Collections.Generic.IReadOnlyCollection<System.String> | topics | The name of the topics or the topic filter strings. |
Unsubscribe(String, IReadOnlyCollection<String>)
Unsubscribes the specified client from the specified topics.
Declaration
void Unsubscribe(string clientId, IReadOnlyCollection<string> topics)
Parameters
Type | Name | Description |
---|---|---|
System.String | clientId | The client identifier. |
System.Collections.Generic.IReadOnlyCollection<System.String> | topics | The name of the topics or the topic filter strings. |
WaitUntilAllMessagesAreConsumedAsync(CancellationToken)
Returns a System.Threading.Tasks.Task that completes when all messages routed to the consumers have been processed and committed.
Declaration
Task WaitUntilAllMessagesAreConsumedAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | A System.Threading.CancellationToken to observe while waiting for the task to complete. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task that completes when all messages have been processed. |