/// <summary>
        /// Enables idempotent sagas. When enabled, sagas derived from <see cref="IdempotentSaga{TSagaData}"/> can be truly idempotent.
        /// This means that the saga instance stores the IDs of all handled messages, including all outgoing messages send when handling
        /// each incoming message - this way, the saga instance can guard itself against handling the same message twice, while still
        /// preserving externally visible behavior even when a message gets handled more than once.
        /// </summary>
        public static void EnableIdempotentSagas(this OptionsConfigurer configurer)
        {
            configurer.Decorate<IPipeline>(c =>
            {
                var transport = c.Get<ITransport>();
                var pipeline = c.Get<IPipeline>();

                var incomingStep = new IdempotentSagaIncomingStep(transport);

                var outgoingStep = new IdempotentSagaOutgoingStep();

                var injector = new PipelineStepInjector(pipeline)
                    .OnReceive(incomingStep, PipelineRelativePosition.Before, typeof (DispatchIncomingMessageStep))
                    .OnSend(outgoingStep, PipelineRelativePosition.After, typeof (SendOutgoingMessageStep));

                return injector;
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Enables idempotent sagas. When enabled, sagas derived from <see cref="IdempotentSaga{TSagaData}"/> can be truly idempotent.
        /// This means that the saga instance stores the IDs of all handled messages, including all outgoing messages send when handling
        /// each incoming message - this way, the saga instance can guard itself against handling the same message twice, while still
        /// preserving externally visible behavior even when a message gets handled more than once.
        /// </summary>
        public static void EnableIdempotentSagas(this OptionsConfigurer configurer)
        {
            configurer.Decorate <IPipeline>(c =>
            {
                var transport = c.Get <ITransport>();
                var pipeline  = c.Get <IPipeline>();

                var incomingStep = new IdempotentSagaIncomingStep(transport);

                var outgoingStep = new IdempotentSagaOutgoingStep();

                var injector = new PipelineStepInjector(pipeline)
                               .OnReceive(incomingStep, PipelineRelativePosition.Before, typeof(DispatchIncomingMessageStep))
                               .OnSend(outgoingStep, PipelineRelativePosition.After, typeof(SendOutgoingMessageStep));

                return(injector);
            });
        }