Example #1
0
        /// <summary>
        /// Enables the data bus
        /// </summary>
        public static StandardConfigurer <IDataBusStorage> EnableDataBus(this OptionsConfigurer configurer)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }

            configurer.Register <IDataBus>(c =>
            {
                var dataBusStorage = GetDataBusStorage(c);

                return(new DefaultDataBus(dataBusStorage));
            });

            configurer.Decorate <IPipeline>(c =>
            {
                var dataBusStorage = GetDataBusStorage(c);
                var pipeline       = c.Get <IPipeline>();

                var step = new DataBusIncomingStep(dataBusStorage);

                return(new PipelineStepInjector(pipeline)
                       .OnReceive(step, PipelineRelativePosition.After, typeof(DeserializeIncomingMessageStep)));
            });

            return(StandardConfigurer <IDataBusStorage> .GetConfigurerFrom(configurer));
        }
    /// <inheritdoc cref="EnableCustomEncryption" />
    public static StandardConfigurer <IAsyncEncryptor> EnableCustomAsyncEncryption(this OptionsConfigurer configurer)
    {
        configurer.Register(c => new EncryptMessagesOutgoingStep(c.Get <IAsyncEncryptor>()));
        configurer.Register(c => new DecryptMessagesIncomingStep(c.Get <IAsyncEncryptor>()));

        configurer.Decorate <IPipeline>(c => new PipelineStepInjector(c.Get <IPipeline>())
                                        .OnReceive(c.Get <DecryptMessagesIncomingStep>(), PipelineRelativePosition.Before, typeof(DeserializeIncomingMessageStep))
                                        .OnSend(c.Get <EncryptMessagesOutgoingStep>(), PipelineRelativePosition.After, typeof(SerializeOutgoingMessageStep)));

        return(StandardConfigurer <IAsyncEncryptor> .GetConfigurerFrom(configurer));
    }
Example #3
0
        /// <summary>
        /// Enables message auditing whereby Rebus will forward to the audit queue a copy of each properly handled message and
        /// each published message
        /// </summary>
        public static StandardConfigurer <ISagaSnapshotStorage> EnableSagaAuditing(this OptionsConfigurer configurer)
        {
            configurer.Decorate <IPipeline>(c =>
            {
                var pipeline            = c.Get <IPipeline>();
                var sagaSnapshotStorage = GetSagaSnapshotStorage(c);
                var transport           = GetTransport(c);

                return(new PipelineStepInjector(pipeline)
                       .OnReceive(new SaveSagaDataSnapshotStep(sagaSnapshotStorage, transport), PipelineRelativePosition.Before, typeof(LoadSagaDataStep)));
            });

            return(StandardConfigurer <ISagaSnapshotStorage> .GetConfigurerFrom(configurer));
        }
    /// <summary>
    /// Configures Rebus to use an outbox.
    /// This will store a (message ID, source queue) tuple for all processed messages, and under this tuple any messages sent/published will
    /// also be stored, thus enabling truly idempotent message processing.
    /// </summary>
    public static RebusConfigurer Outbox(this RebusConfigurer configurer, Action <StandardConfigurer <IOutboxStorage> > configure)
    {
        if (configurer == null)
        {
            throw new ArgumentNullException(nameof(configurer));
        }
        if (configure == null)
        {
            throw new ArgumentNullException(nameof(configure));
        }

        configurer.Options(o =>
        {
            configure(StandardConfigurer <IOutboxStorage> .GetConfigurerFrom(o));

            // if no outbox storage was registered, no further calls must have been made... that's ok, so we just bail out here
            if (!o.Has <IOutboxStorage>())
            {
                return;
            }

            o.Decorate <ITransport>(c => new OutboxClientTransportDecorator(c.Get <ITransport>(), c.Get <IOutboxStorage>()));

            o.Register(c =>
            {
                var asyncTaskFactory   = c.Get <IAsyncTaskFactory>();
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                var outboxStorage      = c.Get <IOutboxStorage>();
                var transport          = c.Get <ITransport>();
                return(new OutboxForwarder(asyncTaskFactory, rebusLoggerFactory, outboxStorage, transport));
            });

            o.Decorate(c =>
            {
                _ = c.Get <OutboxForwarder>();
                return(c.Get <Options>());
            });

            o.Decorate <IPipeline>(c =>
            {
                var pipeline = c.Get <IPipeline>();
                var outboxConnectionProvider = c.Get <IOutboxConnectionProvider>();
                var step = new OutboxIncomingStep(outboxConnectionProvider);
                return(new PipelineStepInjector(pipeline)
                       .OnReceive(step, PipelineRelativePosition.After, typeof(SimpleRetryStrategyStep)));
            });
        });

        return(configurer);
    }
    /// <summary>
    /// Configures Rebus to encrypt outgoing messages and be able to decrypt incoming messages using custom encryption provider.
    /// Please note that it's only the message bodies that are encrypted, thus everything included in the message headers will be visible to eavesdroppers.
    /// Custom encrypotion providers are configured by building on the returned configurer, e.g. like so:
    /// <code>
    /// Configure.With(...)
    ///     .(...)
    ///     .Options(o => {
    ///         o.EnableCustomEncryption()
    ///             .Use***();
    ///     })
    ///     .Start();
    /// </code>
    /// </summary>
    public static StandardConfigurer <IEncryptor> EnableCustomEncryption(this OptionsConfigurer configurer)
    {
        configurer.EnableCustomAsyncEncryption().Register(c => new DefaultAsyncEncryptor(c.Get <IEncryptor>()));

        return(StandardConfigurer <IEncryptor> .GetConfigurerFrom(configurer));
    }