Table of Contents

Class MqttProducerEndpointConfigurationBuilder<TMessage>

Namespace
Silverback.Messaging.Configuration.Mqtt
Assembly
Silverback.Integration.MQTT.dll
public class MqttProducerEndpointConfigurationBuilder<TMessage> : ProducerEndpointConfigurationBuilder<TMessage, MqttProducerEndpointConfiguration, MqttProducerEndpoint, MqttProducerEndpointConfigurationBuilder<TMessage>>, IMessageSerializationBuilder<TMessage, MqttProducerEndpointConfigurationBuilder<TMessage>> where TMessage : class

Type Parameters

TMessage

The type of the messages being produced.

Inheritance
MqttProducerEndpointConfigurationBuilder<TMessage>
Implements
Inherited Members

Constructors

MqttProducerEndpointConfigurationBuilder(IServiceProvider, string?)

Initializes a new instance of the MqttProducerEndpointConfigurationBuilder<TMessage> class.

public MqttProducerEndpointConfigurationBuilder(IServiceProvider serviceProvider, string? friendlyName = null)

Parameters

serviceProvider IServiceProvider

The IServiceProvider.

friendlyName string

An optional friendly to be shown in the human-targeted output (e.g. logs, health checks result, etc.).

Properties

This

Gets this instance.

protected override MqttProducerEndpointConfigurationBuilder<TMessage> This { get; }

Property Value

MqttProducerEndpointConfigurationBuilder<TMessage>

Remarks

This is necessary to work around casting in the base classes.

Methods

CreateConfiguration()

Creates the TConfiguration instance.

protected override MqttProducerEndpointConfiguration CreateConfiguration()

Returns

MqttProducerEndpointConfiguration

The endpoint.

IgnoreNoMatchingSubscribers()

Specifies that no exception should be thrown when no matching subscribers are found for the produced message.

public MqttProducerEndpointConfigurationBuilder<TMessage> IgnoreNoMatchingSubscribers()

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.

LogNoMatchingSubscribersWarning()

Specifies that a warning should be logged when no matching subscribers are found for the produced message.

public MqttProducerEndpointConfigurationBuilder<TMessage> LogNoMatchingSubscribersWarning()

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.

ProduceTo(Func<TMessage?, string>)

Specifies the functions returning the target topic for each message being produced.

public MqttProducerEndpointConfigurationBuilder<TMessage> ProduceTo(Func<TMessage?, string> topicFunction)

Parameters

topicFunction Func<TMessage, string>

The function returning the target topic for the message being produced.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.

ProduceTo(string)

Specifies the target topic and optionally the target partition.

public MqttProducerEndpointConfigurationBuilder<TMessage> ProduceTo(string topic)

Parameters

topic string

The target topic.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.

ProduceTo(string, Func<TMessage?, string[]>)

Specifies the target topic format.

public MqttProducerEndpointConfigurationBuilder<TMessage> ProduceTo(string topicFormatString, Func<TMessage?, string[]> topicArgumentsFunction)

Parameters

topicFormatString string

The topic format string that will be combined with the arguments returned by the topicArgumentsFunction using a Format(string, params object[]).

topicArgumentsFunction Func<TMessage, string[]>

The function returning the arguments to be used to format the string.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.

ProduceToDynamicTopic()

Specifies that the target topic and, optionally, the target partition will be specified per each message using the envelope's SetMqttDestinationTopic(IOutboundEnvelope, string) extension method.

public MqttProducerEndpointConfigurationBuilder<TMessage> ProduceToDynamicTopic()

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.

Retain()

Specifies that the messages have to be sent with the retain flag, causing them to be persisted on the broker.

public MqttProducerEndpointConfigurationBuilder<TMessage> Retain()

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.

SetCorrelationData(byte[]?)

Sets the specified correlation data to all produced messages.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetCorrelationData(byte[]? correlationData)

Parameters

correlationData byte[]

The correlation data.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

SetCorrelationData(Func<IOutboundEnvelope<TMessage>, byte[]?>)

Sets the correlation data to all produced messages, using a provider function to determine the correlation data for each message.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetCorrelationData(Func<IOutboundEnvelope<TMessage>, byte[]?> correlationDataProvider)

Parameters

correlationDataProvider Func<IOutboundEnvelope<TMessage>, byte[]>

The correlation data provider function.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

SetCorrelationData(Func<IOutboundEnvelope<TMessage>, string?>)

Sets the correlation data to all produced messages, using a provider function to determine the correlation data for each message.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetCorrelationData(Func<IOutboundEnvelope<TMessage>, string?> correlationDataProvider)

Parameters

correlationDataProvider Func<IOutboundEnvelope<TMessage>, string>

The correlation data provider function.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

SetCorrelationData(Func<TMessage?, byte[]?>)

Sets the correlation data to all produced messages, using a provider function to determine the correlation data for each message.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetCorrelationData(Func<TMessage?, byte[]?> correlationDataProvider)

Parameters

correlationDataProvider Func<TMessage, byte[]>

The correlation data provider function.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

SetCorrelationData(Func<TMessage?, string?>)

Sets the correlation data to all produced messages, using a provider function to determine the correlation data for each message.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetCorrelationData(Func<TMessage?, string?> correlationDataProvider)

Parameters

correlationDataProvider Func<TMessage, string>

The correlation data provider function.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

SetCorrelationData(string?)

Sets the specified correlation data to all produced messages.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetCorrelationData(string? correlationData)

Parameters

correlationData string

The correlation data.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

SetCorrelationData<TMessageChildType>(byte[]?)

Sets the specified correlation data to all produced messages of the specified child type.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetCorrelationData<TMessageChildType>(byte[]? correlationData) where TMessageChildType : TMessage

Parameters

correlationData byte[]

The correlation data.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

Type Parameters

TMessageChildType

The type of the messages to be enriched with this header.

SetCorrelationData<TMessageChildType>(Func<IOutboundEnvelope<TMessageChildType>, byte[]?>)

Sets the correlation data to all produced messages of the specified child type, using a provider function to determine the correlation data for each message.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetCorrelationData<TMessageChildType>(Func<IOutboundEnvelope<TMessageChildType>, byte[]?> correlationDataProvider) where TMessageChildType : TMessage

Parameters

correlationDataProvider Func<IOutboundEnvelope<TMessageChildType>, byte[]>

The correlation data provider function.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

Type Parameters

TMessageChildType

The type of the messages to be enriched with this header.

SetCorrelationData<TMessageChildType>(Func<IOutboundEnvelope<TMessageChildType>, string?>)

Sets the correlation data to all produced messages of the specified child type, using a provider function to determine the correlation data for each message.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetCorrelationData<TMessageChildType>(Func<IOutboundEnvelope<TMessageChildType>, string?> correlationDataProvider) where TMessageChildType : TMessage

Parameters

correlationDataProvider Func<IOutboundEnvelope<TMessageChildType>, string>

The correlation data provider function.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

Type Parameters

TMessageChildType

The type of the messages to be enriched with this header.

SetCorrelationData<TMessageChildType>(Func<TMessageChildType?, byte[]?>)

Sets the correlation data to all produced messages of the specified child type, using a provider function to determine the correlation data for each message.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetCorrelationData<TMessageChildType>(Func<TMessageChildType?, byte[]?> correlationDataProvider) where TMessageChildType : TMessage

Parameters

correlationDataProvider Func<TMessageChildType, byte[]>

The correlation data provider function.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

Type Parameters

TMessageChildType

The type of the messages to be enriched with this header.

SetCorrelationData<TMessageChildType>(Func<TMessageChildType?, string?>)

Sets the correlation data to all produced messages of the specified child type, using a provider function to determine the correlation data for each message.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetCorrelationData<TMessageChildType>(Func<TMessageChildType?, string?> correlationDataProvider) where TMessageChildType : TMessage

Parameters

correlationDataProvider Func<TMessageChildType, string>

The correlation data provider function.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

Type Parameters

TMessageChildType

The type of the messages to be enriched with this header.

SetCorrelationData<TMessageChildType>(string?)

Sets the specified correlation data to all produced messages of the specified child type.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetCorrelationData<TMessageChildType>(string? correlationData) where TMessageChildType : TMessage

Parameters

correlationData string

The correlation data.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

Type Parameters

TMessageChildType

The type of the messages to be enriched with this header.

SetResponseTopic(Func<IOutboundEnvelope<TMessage>, string?>)

Sets the response topic to all produced messages, using a provider function to determine the response topic for each message.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetResponseTopic(Func<IOutboundEnvelope<TMessage>, string?> responseTopicProvider)

Parameters

responseTopicProvider Func<IOutboundEnvelope<TMessage>, string>

The response topic provider function.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

SetResponseTopic(Func<TMessage?, string?>)

Sets the response topic to all produced messages, using a provider function to determine the response topic for each message.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetResponseTopic(Func<TMessage?, string?> responseTopicProvider)

Parameters

responseTopicProvider Func<TMessage, string>

The response topic provider function.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

SetResponseTopic(string?)

Sets the specified response topic to all produced messages.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetResponseTopic(string? responseTopic)

Parameters

responseTopic string

The response topic.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

SetResponseTopic<TMessageChildType>(Func<IOutboundEnvelope<TMessageChildType>, string?>)

Sets the response topic to all produced messages of the specified child type, using a provider function to determine the response topic for each message.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetResponseTopic<TMessageChildType>(Func<IOutboundEnvelope<TMessageChildType>, string?> responseTopicProvider) where TMessageChildType : TMessage

Parameters

responseTopicProvider Func<IOutboundEnvelope<TMessageChildType>, string>

The response topic provider function.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

Type Parameters

TMessageChildType

The type of the messages to be enriched with this header.

SetResponseTopic<TMessageChildType>(Func<TMessageChildType?, string?>)

Sets the response topic to all produced messages of the specified child type, using a provider function to determine the response topic for each message.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetResponseTopic<TMessageChildType>(Func<TMessageChildType?, string?> responseTopicProvider) where TMessageChildType : TMessage

Parameters

responseTopicProvider Func<TMessageChildType, string>

The response topic provider function.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

Type Parameters

TMessageChildType

The type of the messages to be enriched with this header.

SetResponseTopic<TMessageChildType>(string)

Sets the specified response topic to all produced messages of the specified child type.

public MqttProducerEndpointConfigurationBuilder<TMessage> SetResponseTopic<TMessageChildType>(string responseTopic) where TMessageChildType : TMessage

Parameters

responseTopic string

The response topic.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The endpoint builder so that additional calls can be chained.

Type Parameters

TMessageChildType

The type of the messages to be enriched with this header.

ThrowNoMatchingSubscribersError()

Specifies that an exception should be thrown when no matching subscribers are found for the produced message.

public MqttProducerEndpointConfigurationBuilder<TMessage> ThrowNoMatchingSubscribersError()

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.

UseEndpointResolver<TResolver>()

Specifies the type of the IMqttProducerEndpointResolver<TMessage> to be used to resolve the target topic for each message being produced.

public MqttProducerEndpointConfigurationBuilder<TMessage> UseEndpointResolver<TResolver>() where TResolver : IMqttProducerEndpointResolver<TMessage>

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.

Type Parameters

TResolver

The type of the IMqttProducerEndpointResolver<TMessage> to be used.

WithAtLeastOnceQoS()

Specifies that the messages have to be sent with the at least once quality of service level.

public MqttProducerEndpointConfigurationBuilder<TMessage> WithAtLeastOnceQoS()

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.

WithAtMostOnceQoS()

Specifies that the messages have to be sent with the at most once quality of service level.

public MqttProducerEndpointConfigurationBuilder<TMessage> WithAtMostOnceQoS()

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.

WithExactlyOnceQoS()

Specifies that the messages have to be sent with the exactly once quality of service level.

public MqttProducerEndpointConfigurationBuilder<TMessage> WithExactlyOnceQoS()

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.

WithMessageExpiration(TimeSpan)

Sets the message expiry interval. This interval defines the period of time that the broker stores the PUBLISH message for any matching subscribers that are not currently connected. When no message expiry interval is set, the broker must store the message for matching subscribers indefinitely.

public MqttProducerEndpointConfigurationBuilder<TMessage> WithMessageExpiration(TimeSpan messageExpiryInterval)

Parameters

messageExpiryInterval TimeSpan

The TimeSpan representing the message expiry interval.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.

WithQualityOfServiceLevel(MqttQualityOfServiceLevel)

Specifies the desired quality of service level.

public MqttProducerEndpointConfigurationBuilder<TMessage> WithQualityOfServiceLevel(MqttQualityOfServiceLevel qosLevel)

Parameters

qosLevel MqttQualityOfServiceLevel

The MQTTnet.Protocol.MqttQualityOfServiceLevel.

Returns

MqttProducerEndpointConfigurationBuilder<TMessage>

The MqttProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.