Exemple #1
0
        /// <summary>
        /// Connects the saga to the bus
        /// </summary>
        /// <typeparam name="T">The saga type</typeparam>
        /// <param name="bus">The bus to which the saga is to be connected</param>
        /// <param name="sagaRepository">The saga repository</param>
        /// <param name="pipeSpecifications"></param>
        public static ConnectHandle ConnectSaga <T>(this IConsumePipeConnector bus, ISagaRepository <T> sagaRepository,
                                                    params IPipeSpecification <SagaConsumeContext <T> >[] pipeSpecifications)
            where T : class, ISaga
        {
            if (bus == null)
            {
                throw new ArgumentNullException(nameof(bus));
            }
            if (sagaRepository == null)
            {
                throw new ArgumentNullException(nameof(sagaRepository));
            }

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Subscribing Saga: {0}", TypeMetadataCache <T> .ShortName);
            }

            ISagaSpecification <T> specification = SagaConnectorCache <T> .Connector.CreateSagaSpecification <T>();

            foreach (IPipeSpecification <SagaConsumeContext <T> > pipeSpecification in pipeSpecifications)
            {
                specification.AddPipeSpecification(pipeSpecification);
            }

            return(SagaConnectorCache <T> .Connector.ConnectSaga(bus, sagaRepository, specification));
        }
        /// <summary>
        /// Connects the saga to the bus
        /// </summary>
        /// <typeparam name="T">The saga type</typeparam>
        /// <param name="connector">The bus to which the saga is to be connected</param>
        /// <param name="sagaRepository">The saga repository</param>
        /// <param name="pipeSpecifications"></param>
        public static ConnectHandle ConnectSaga <T>(this IConsumePipeConnector connector, ISagaRepository <T> sagaRepository,
                                                    params IPipeSpecification <SagaConsumeContext <T> >[] pipeSpecifications)
            where T : class, ISaga
        {
            if (connector == null)
            {
                throw new ArgumentNullException(nameof(connector));
            }
            if (sagaRepository == null)
            {
                throw new ArgumentNullException(nameof(sagaRepository));
            }

            LogContext.Debug?.Log("Connecting Saga: {SagaType}", TypeMetadataCache <T> .ShortName);

            ISagaSpecification <T> specification = SagaConnectorCache <T> .Connector.CreateSagaSpecification <T>();

            foreach (IPipeSpecification <SagaConsumeContext <T> > pipeSpecification in pipeSpecifications)
            {
                specification.AddPipeSpecification(pipeSpecification);
            }

            return(SagaConnectorCache <T> .Connector.ConnectSaga(connector, sagaRepository, specification));
        }
Exemple #3
0
 public void AddPipeSpecification(IPipeSpecification <SagaConsumeContext <TInstance> > specification)
 {
     _specification.AddPipeSpecification(specification);
 }