Beispiel #1
0
        private static MqttProducerEndpoint BuildEndpoint(
            Action <IMqttProducerEndpointBuilder> builderAction,
            MqttClientConfig clientConfig)
        {
            var builder = new MqttProducerEndpointBuilder(clientConfig);

            builderAction.Invoke(builder);

            return(builder.Build());
        }
Beispiel #2
0
        /// <summary>
        ///     Adds a <see cref="MoveMessageErrorPolicy" /> that moves the messages that fail to be processed to the
        ///     configured endpoint.
        /// </summary>
        /// <param name="builder">
        ///     The <see cref="IErrorPolicyChainBuilder" />.
        /// </param>
        /// <param name="endpointBuilderAction">
        ///     An <see cref="Action{T}" /> that takes the <see cref="IMqttProducerEndpointBuilder" /> and configures
        ///     it.
        /// </param>
        /// <param name="policyConfigurationAction">
        ///     The (optional) additional configuration.
        /// </param>
        /// <returns>
        ///     The <see cref="IErrorPolicyChainBuilder" /> so that additional calls can be chained.
        /// </returns>
        public static IErrorPolicyChainBuilder ThenMoveToMqttTopic(
            this IErrorPolicyChainBuilder builder,
            Action <IMqttProducerEndpointBuilder> endpointBuilderAction,
            Action <MoveMessageErrorPolicy>?policyConfigurationAction = null)
        {
            Check.NotNull(builder, nameof(builder));
            Check.NotNull(endpointBuilderAction, nameof(endpointBuilderAction));

            MqttEndpointsConfigurationBuilder?endpointsConfigurationBuilder =
                (builder as ErrorPolicyChainBuilder)?.EndpointsConfigurationBuilder as
                MqttEndpointsConfigurationBuilder;

            var mqttClientConfig = endpointsConfigurationBuilder?.ClientConfig ??
                                   throw new InvalidOperationException("Missing ClientConfig.");

            var endpointBuilder = new MqttProducerEndpointBuilder(mqttClientConfig);

            endpointBuilderAction(endpointBuilder);

            return(builder.ThenMove(endpointBuilder.Build(), policyConfigurationAction));
        }