Exemple #1
0
        protected override void Init()
        {
            foreach (var initStep in m_InitSteps)
            {
                initStep(Kernel);
            }
            var transports = MessagingConfiguration.GetTransports();

            if (Kernel.HasComponent(typeof(IEndpointProvider)))
            {
                throw new Exception("IEndpointProvider already registered in container, can not register IEndpointProvider from MessagingConfiguration");
            }
            Kernel.Register(
                Component.For <IEndpointProvider>()
                .Forward <ISubDependencyResolver>()
                .ImplementedBy <EndpointResolver>()
                .Named("EndpointResolver")
                .DependsOn(new { endpoints = MessagingConfiguration.GetEndpoints() }));
            var endpointResolver = Kernel.Resolve <ISubDependencyResolver>("EndpointResolver");

            Kernel.Resolver.AddSubResolver(endpointResolver);


            m_MessagingEngine = new MessagingEngine(new TransportResolver(transports ?? new Dictionary <string, TransportInfo>(), m_JailStrategies),
                                                    m_TransportFactories.ToArray());

            Kernel.Register(
                Component.For <IMessagingEngine>().Instance(m_MessagingEngine)
                );
            Kernel.ComponentRegistered   += onComponentRegistered;
            Kernel.ComponentModelCreated += ProcessModel;
        }
Exemple #2
0
        private CqrsEngine CreateEngine(IComponentContext ctx, IMessagingEngine messagingEngine)
        {
            var rabbitMqConventionEndpointResolver =
                new RabbitMqConventionEndpointResolver("RabbitMq", "messagepack",
                                                       environment: _settings.EnvironmentName);

            var registrations = new List <IRegistration>
            {
                Register.DefaultEndpointResolver(rabbitMqConventionEndpointResolver),
                RegisterDefaultRouting(),
                RegisterSpecialLiquidationSaga(),
                RegisterLiquidationSaga(),
                RegisterContext(),
            };

            var fakeGavel = RegisterGavelContextIfNeeded();

            if (fakeGavel != null)
            {
                registrations.Add(fakeGavel);
            }

            return(new CqrsEngine(_log, ctx.Resolve <IDependencyResolver>(), messagingEngine,
                                  new DefaultEndpointProvider(), true, registrations.ToArray()));
        }
Exemple #3
0
        private static CqrsEngine CreateEngine(ILogFactory logFactory, IMessagingEngine messagingEngine)
        {
            var registrations = new IRegistration[]
            {
                Register.DefaultEndpointResolver(new RabbitMqConventionEndpointResolver
                                                 (
                                                     "RabbitMq",
                                                     SerializationFormat.MessagePack,
                                                     environment: "lykke"
                                                 )),

                Register.BoundedContext(BlockchainWalletsBoundedContext.Name)
                .PublishingEvents(typeof(WalletCreatedEvent))
                .With(BlockchainWalletsBoundedContext.EventsRoute)
            };

            return(new CqrsEngine
                   (
                       logFactory,
                       null,
                       messagingEngine,
                       new DefaultEndpointProvider(),
                       true,
                       registrations));
        }
        private CqrsEngine CreateEngine(IComponentContext ctx, IMessagingEngine messagingEngine)
        {
            var rabbitMqConventionEndpointResolver = new RabbitMqConventionEndpointResolver(
                "RabbitMq",
                SerializationFormat.MessagePack,
                environment: _settings.EnvironmentName);

            var engine = new CqrsEngine(
                _log,
                ctx.Resolve <IDependencyResolver>(),
                messagingEngine,
                new DefaultEndpointProvider(),
                true,
                Register.DefaultEndpointResolver(rabbitMqConventionEndpointResolver),
                RegisterDefaultRouting(),
                RegisterWithdrawalSaga(),
                RegisterDepositSaga(),
                RegisterClosePositionSaga(),
                RegisterNegativeProtectionSaga(),
                RegisterGiveTemporaryCapitalSaga(),
                RegisterRevokeTemporaryCapitalSaga(),
                RegisterDeleteAccountsSaga(),
                RegisterContext(),
                Register.CommandInterceptors(new DefaultCommandLoggingInterceptor(_log)),
                Register.EventInterceptors(new DefaultEventLoggingInterceptor(_log)));
            var correlationManager = ctx.Resolve <CqrsCorrelationManager>();

            engine.SetReadHeadersAction(correlationManager.FetchCorrelationIfExists);
            engine.SetWriteHeadersFunc(correlationManager.BuildCorrelationHeadersIfExists);
            engine.StartAll();

            return(engine);
        }
Exemple #5
0
        private CqrsEngine CreateEngine(IComponentContext ctx, IMessagingEngine messagingEngine)
        {
            var rabbitMqConventionEndpointResolver =
                new RabbitMqConventionEndpointResolver("RabbitMq", SerializationFormat.MessagePack,
                                                       environment: _settings.EnvironmentName);

            var registrations = new List <IRegistration>
            {
                Register.DefaultEndpointResolver(rabbitMqConventionEndpointResolver),
                RegisterDefaultRouting(),
                RegisterSpecialLiquidationSaga(),
                RegisterLiquidationSaga(),
                RegisterContext(),
                Register.CommandInterceptors(new DefaultCommandLoggingInterceptor(_log)),
                Register.EventInterceptors(new DefaultEventLoggingInterceptor(_log))
            };

            var fakeGavel = RegisterGavelContextIfNeeded();

            if (fakeGavel != null)
            {
                registrations.Add(fakeGavel);
            }

            var correlationManager = ctx.Resolve <CqrsCorrelationManager>();
            var engine             = new CqrsEngine(_log, ctx.Resolve <IDependencyResolver>(), messagingEngine,
                                                    new DefaultEndpointProvider(), true, registrations.ToArray());

            engine.SetReadHeadersAction(correlationManager.FetchCorrelationIfExists);
            engine.SetWriteHeadersFunc(correlationManager.BuildCorrelationHeadersIfExists);
            engine.StartPublishers();

            return(engine);
        }
Exemple #6
0
        public bool PublishMessage(
            IMessagingEngine messagingEngine,
            Type type,
            object message,
            RouteType routeType,
            uint priority,
            string remoteBoundedContext = null)
        {
            var publishDirections = (
                from route in this
                from messageRoute in route.MessageRoutes
                where messageRoute.Key.MessageType == type &&
                messageRoute.Key.RouteType == routeType &&
                messageRoute.Key.Priority == priority &&
                messageRoute.Key.RemoteBoundedContext == remoteBoundedContext
                select new
            {
                processingGroup = route.ProcessingGroupName,
                endpoint = messageRoute.Value
            }
                ).ToArray();

            if (!publishDirections.Any())
            {
                return(false);
            }
            foreach (var direction in publishDirections)
            {
                messagingEngine.Send(message, direction.endpoint, direction.processingGroup);
            }
            return(true);
        }
Exemple #7
0
 public HbSender(IHost host, IMessagingEngine engine, Endpoint hbEndpoint, ILogger logger, string environment, int hbInterval)
 {
     m_HbInterval   = hbInterval == 0?DEFAULT_HB_INTERVAL:hbInterval;
     m_Logger       = logger;
     m_Engine       = engine;
     m_HbEndpoint   = hbEndpoint;
     m_Host         = host;
     m_InstanceName = string.Format("{0}({1})", Environment.MachineName, environment);
 }
Exemple #8
0
 public CqrsEngine(IDependencyResolver dependencyResolver, IMessagingEngine messagingEngine, IEndpointResolver endpointResolver, bool createMissingEndpoints, params IRegistration[] registrations)
 {
     m_Logger.Debug("CqrsEngine instanciating. createMissingEndpoints: " + createMissingEndpoints);
     m_CreateMissingEndpoints = createMissingEndpoints;
     m_DependencyResolver     = dependencyResolver;
     m_Registrations          = registrations;
     m_EndpointResolver       = endpointResolver;
     m_MessagingEngine        = messagingEngine;
     m_BoundedContexts        = new List <BoundedContext>();
     init();
 }
Exemple #9
0
 public CqrsEngine(
     ILog log,
     IMessagingEngine messagingEngine,
     params IRegistration[] registrations)
     : this(
         log,
         new DefaultDependencyResolver(),
         messagingEngine,
         new DefaultEndpointProvider(),
         false,
         registrations)
 {
 }
Exemple #10
0
 public CqrsEngine(
     ILogFactory logFactory,
     IMessagingEngine messagingEngine,
     IEndpointProvider endpointProvider,
     params IRegistration[] registrations)
     : this(
         logFactory,
         new DefaultDependencyResolver(),
         messagingEngine,
         endpointProvider,
         false,
         registrations)
 {
 }
Exemple #11
0
 public CqrsEngine(
     ILog log,
     IDependencyResolver dependencyResolver,
     IMessagingEngine messagingEngine,
     IEndpointProvider endpointProvider,
     params IRegistration[] registrations)
     : this(
         log,
         dependencyResolver,
         messagingEngine,
         endpointProvider,
         false,
         registrations)
 {
 }
Exemple #12
0
 public CqrsEngine(
     ILogFactory logFactory,
     IDependencyResolver dependencyResolver,
     IMessagingEngine messagingEngine,
     IEndpointProvider endpointProvider,
     bool createMissingEndpoints,
     params IRegistration[] registrations)
     : this(
         logFactory,
         dependencyResolver,
         messagingEngine,
         endpointProvider,
         createMissingEndpoints,
         true,
         registrations)
 {
 }
        private CqrsEngine CreateEngine(IComponentContext ctx, IMessagingEngine messagingEngine)
        {
            var rabbitMqConventionEndpointResolver =
                new RabbitMqConventionEndpointResolver("RabbitMq", SerializationFormat.MessagePack,
                                                       environment: _settings.EnvironmentName);

            var registrations = new List <IRegistration>
            {
                Register.DefaultEndpointResolver(rabbitMqConventionEndpointResolver),
                Register.CommandInterceptors(new DefaultCommandLoggingInterceptor(_log)),
                Register.EventInterceptors(new DefaultEventLoggingInterceptor(_log)),
                RegisterContext(),
            };

            return(new CqrsEngine(_log, ctx.Resolve <IDependencyResolver>(), messagingEngine,
                                  new DefaultEndpointProvider(), true, registrations.ToArray()));
        }
Exemple #14
0
 public CqrsEngine(
     ILog log,
     IDependencyResolver dependencyResolver,
     IMessagingEngine messagingEngine,
     IEndpointProvider endpointProvider,
     bool createMissingEndpoints,
     bool enableInputMessagesLogging,
     params IRegistration[] registrations)
 {
     Log = log;
     _createMissingEndpoints = createMissingEndpoints;
     DependencyResolver      = dependencyResolver;
     _registrations          = registrations;
     EndpointResolver        = new DefaultEndpointResolver();
     MessagingEngine         = messagingEngine;
     _endpointProvider       = endpointProvider;
     Contexts                   = new List <Context>();
     DefaultRouteMap            = new RouteMap("default");
     EnableInputMessagesLogging = enableInputMessagesLogging;
 }
Exemple #15
0
        public CqrsEngine(
            ILog log,
            IDependencyResolver dependencyResolver,
            IMessagingEngine messagingEngine,
            IEndpointProvider endpointProvider,
            bool createMissingEndpoints,
            params IRegistration[] registrations)
        {
            _log = log;
            _createMissingEndpoints = createMissingEndpoints;
            DependencyResolver      = dependencyResolver;
            EndpointResolver        = new DefaultEndpointResolver();
            MessagingEngine         = messagingEngine;
            _endpointProvider       = endpointProvider;
            Contexts                 = new List <Context>();
            DefaultRouteMap          = new RouteMap("default");
            CommandInterceptorsQueue = new CommandInterceptorsQueue();
            EventInterceptorsQueue   = new EventInterceptorsQueue();

            InitRegistrations(registrations);
        }
Exemple #16
0
        private CqrsEngine CreateEngine(IComponentContext ctx, IMessagingEngine messagingEngine)
        {
            var rabbitMqConventionEndpointResolver = new RabbitMqConventionEndpointResolver(
                "RabbitMq",
                SerializationFormat.MessagePack,
                environment: _settings.EnvironmentName);

            var engine = new CqrsEngine(
                _log,
                ctx.Resolve <IDependencyResolver>(),
                messagingEngine,
                new DefaultEndpointProvider(),
                true,
                Register.DefaultEndpointResolver(rabbitMqConventionEndpointResolver),
                RegisterDefaultRouting(),
                RegisterContext(),
                Register.CommandInterceptors(new DefaultCommandLoggingInterceptor(_log)),
                Register.EventInterceptors(new DefaultEventLoggingInterceptor(_log)));

            engine.StartPublishers();

            return(engine);
        }
Exemple #17
0
        private CqrsEngine CreateEngine(
            IComponentContext ctx,
            IMessagingEngine messagingEngine,
            ILogFactory logFactory)
        {
            const string defaultRoute = "self";

            return(new CqrsEngine(
                       logFactory,
                       ctx.Resolve <IDependencyResolver>(),
                       messagingEngine,
                       new DefaultEndpointProvider(),
                       true,
                       Register.DefaultEndpointResolver(new InMemoryEndpointResolver()),

                       Register.BoundedContext(HistoryBoundedContext.Name)
                       .ListeningCommands(typeof(CreateForwardCashinCommand), typeof(DeleteForwardCashinCommand))
                       .On(defaultRoute)
                       .WithLoopback()
                       .WithCommandsHandler <ForwardWithdrawalCommandHandler>()
                       .PublishingEvents(typeof(ForwardCashinCreatedEvent), typeof(ForwardCashinDeletedEvent))
                       .With("events")));
        }
        private CqrsEngine CreateEngine(
            IComponentContext ctx,
            IMessagingEngine messagingEngine,
            ILogFactory logFactory)
        {
            const string defaultRoute = "self";

            var sagasMessagePackEndpointResolver = new RabbitMqConventionEndpointResolver(
                "RabbitMq",
                SerializationFormat.MessagePack,
                environment: "lykke");

            var sagasProtobufEndpointResolver = new RabbitMqConventionEndpointResolver(
                "RabbitMq",
                SerializationFormat.ProtoBuf,
                environment: "lykke");

            return(new CqrsEngine(
                       logFactory,
                       ctx.Resolve <IDependencyResolver>(),
                       messagingEngine,
                       new DefaultEndpointProvider(),
                       true,
                       Register.DefaultEndpointResolver(sagasProtobufEndpointResolver),

                       Register.EventInterceptors(new DefaultEventLoggingInterceptor(ctx.Resolve <ILogFactory>())),

                       Register.BoundedContext(HistoryBoundedContext.Name)

                       .ListeningEvents(typeof(CashoutCompletedEvent), typeof(CashinCompletedEvent))
                       .From(BitcoinBoundedContext.Name)
                       .On(defaultRoute)
                       .WithEndpointResolver(sagasMessagePackEndpointResolver)
                       .WithProjection(typeof(TransactionHashProjection), BitcoinBoundedContext.Name)

                       .ListeningEvents(typeof(Lykke.Job.BlockchainCashinDetector.Contract.Events.CashinCompletedEvent))
                       .From(BlockchainCashinDetectorBoundedContext.Name)
                       .On(defaultRoute)
                       .WithEndpointResolver(sagasMessagePackEndpointResolver)
                       .WithProjection(typeof(TransactionHashProjection), BlockchainCashinDetectorBoundedContext.Name)

                       .ListeningEvents(typeof(Lykke.Job.SiriusDepositsDetector.Contract.Events.CashinCompletedEvent))
                       .From(SiriusDepositsDetectorBoundedContext.Name)
                       .On(defaultRoute)
                       .WithEndpointResolver(sagasMessagePackEndpointResolver)
                       .WithProjection(typeof(TransactionHashProjection), SiriusDepositsDetectorBoundedContext.Name)

                       .ListeningEvents(typeof(Lykke.Job.SiriusCashoutProcessor.Contract.Events.CashoutCompletedEvent))
                       .From(SiriusCashoutProcessorBoundedContext.Name)
                       .On(defaultRoute)
                       .WithEndpointResolver(sagasMessagePackEndpointResolver)
                       .WithProjection(typeof(TransactionHashProjection), SiriusCashoutProcessorBoundedContext.Name)

                       .ListeningEvents(
                           typeof(Lykke.Job.BlockchainCashoutProcessor.Contract.Events.CashoutCompletedEvent),
                           typeof(Lykke.Job.BlockchainCashoutProcessor.Contract.Events.CrossClientCashoutCompletedEvent),
                           typeof(Lykke.Job.BlockchainCashoutProcessor.Contract.Events.CashoutsBatchCompletedEvent))
                       .From(BlockchainCashoutProcessorBoundedContext.Name)
                       .On(defaultRoute)
                       .WithEndpointResolver(sagasMessagePackEndpointResolver)
                       .WithProjection(typeof(TransactionHashProjection), BlockchainCashoutProcessorBoundedContext.Name)

                       .ListeningCommands(typeof(CreateForwardCashinCommand), typeof(DeleteForwardCashinCommand))
                       .On("commands")
                       .WithCommandsHandler <ForwardWithdrawalCommandHandler>()
                       .PublishingEvents(typeof(ForwardCashinCreatedEvent), typeof(ForwardCashinDeletedEvent))
                       .With("events"),

                       Register.BoundedContext("tx-handler.ethereum.commands")
                       .ListeningCommands(typeof(SaveEthInHistoryCommand), typeof(ProcessEthCoinEventCommand),
                                          typeof(ProcessHotWalletErc20EventCommand))
                       .On("history")
                       .WithEndpointResolver(sagasMessagePackEndpointResolver)
                       .WithCommandsHandler <EthereumCommandHandler>()));
        }
        private CqrsEngine CreateEngine(
            IComponentContext ctx,
            IMessagingEngine messagingEngine,
            ILogFactory logFactory)
        {
            const string defaultPipeline = "commands";
            const string defaultRoute    = "self";

            var sagasMessagePackEndpointResolver = new RabbitMqConventionEndpointResolver(
                "RabbitMq",
                SerializationFormat.MessagePack,
                environment: "lykke");

            var sagasProtobufEndpointResolver = new RabbitMqConventionEndpointResolver(
                "RabbitMq",
                SerializationFormat.ProtoBuf,
                environment: "lykke");

            var engine = new CqrsEngine(
                logFactory,
                ctx.Resolve <IDependencyResolver>(),
                messagingEngine,
                new DefaultEndpointProvider(),
                true,
                Register.DefaultEndpointResolver(sagasMessagePackEndpointResolver),

                Register.EventInterceptors(new DefaultEventLoggingInterceptor(ctx.Resolve <ILogFactory>())),
                Register.CommandInterceptors(new DefaultCommandLoggingInterceptor(ctx.Resolve <ILogFactory>())),

                Register.BoundedContext(BoundedContext.ForwardWithdrawal)
                .ListeningCommands(
                    typeof(ProcessPaymentCommand),
                    typeof(RemoveEntryCommand),
                    typeof(RemoveEntryFromHistoryJobCommand),
                    typeof(RemoveEntryFromHistoryServiceCommand))
                .On(defaultRoute)
                .PublishingEvents(
                    typeof(PaymentEntryRemovedEvent),
                    typeof(CashInRemovedFromHistoryJobEvent),
                    typeof(CashInRemovedFromHistoryServiceEvent),
                    typeof(CashInProcesedEvent))
                .With(defaultPipeline)
                .WithCommandsHandler(typeof(CommandsHandler)),
                Register.Saga <PaymentSaga>("payment-saga")
                .ListeningEvents(
                    typeof(PaymentEntryRemovedEvent),
                    typeof(CashInRemovedFromHistoryJobEvent),
                    typeof(CashInRemovedFromHistoryServiceEvent),
                    typeof(CashInProcesedEvent))
                .From(BoundedContext.ForwardWithdrawal).On(defaultRoute)
                .PublishingCommands(
                    typeof(ProcessPaymentCommand),
                    typeof(RemoveEntryCommand),
                    typeof(RemoveEntryFromHistoryJobCommand),
                    typeof(RemoveEntryFromHistoryServiceCommand))
                .To(BoundedContext.ForwardWithdrawal).With(defaultPipeline)
                .PublishingCommands(
                    typeof(DeleteForwardCashinCommand))
                .To(HistoryBoundedContext.Name)
                .With(defaultPipeline)
                .WithEndpointResolver(sagasProtobufEndpointResolver),
                Register.Saga <CashoutsSaga>("cashouts-saga")
                .ListeningEvents(typeof(CashOutProcessedEvent))
                .From(PostProcessingBoundedContext.Name)
                .On(defaultRoute)
                .WithEndpointResolver(sagasProtobufEndpointResolver)
                .PublishingCommands(
                    typeof(CreateForwardCashinCommand))
                .To(HistoryBoundedContext.Name)
                .With(defaultPipeline)
                .WithEndpointResolver(sagasProtobufEndpointResolver),
                Register.DefaultRouting
                .PublishingCommands(typeof(RemoveEntryCommand))
                .To(BoundedContext.ForwardWithdrawal)
                .With(defaultPipeline));

            engine.StartPublishers();

            return(engine);
        }
 protected MessagingFeedWithHbProviderBaseMock(IMessagingEngine transportEngine, long timeout)
     : base(transportEngine, timeout)
 {
 }
 protected MessagingFeedProviderBase(IMessagingEngine messagingEngine)
     : base(messagingEngine)
 {
 }
Exemple #22
0
 public FeedProvider2(IMessagingEngine messagingEngine, long initTimeout = 30000)
     : base(messagingEngine, initTimeout)
 {
 }
Exemple #23
0
 public HbFeedProvider(IMessagingEngine messagingEngine, Endpoint hbEndpoint)
     : base(messagingEngine)
 {
     m_HbEndpoint = hbEndpoint;
 }
 protected MessagingFeedWithHbProviderBase(IMessagingEngine messagingEngine, long initTimeout = 30000)
     : base(messagingEngine, initTimeout)
 {
 }
Exemple #25
0
 protected MessagingFeedWithInitializationMock(IMessagingEngine messagingEngine)
     : base(messagingEngine)
 {
 }
Exemple #26
0
 /// <summary>
 /// Creates new instance of MessagingFeedProvider
 /// </summary>
 /// <param name="messagingEngine">Messaging engine</param>
 /// <param name="endpoint">Endpoint</param>
 public MessagingFeedProvider(IMessagingEngine messagingEngine, Endpoint endpoint)
     : base(messagingEngine)
 {
     m_Endpoint = endpoint;
 }
Exemple #27
0
 public CqrsEngine(IMessagingEngine messagingEngine, IEndpointResolver endpointResolver, params IRegistration[] registrations)
     : this(new DefaultDependencyResolver(), messagingEngine, endpointResolver, registrations)
 {
 }
 protected MessagingFeedWithInitializationBase(IMessagingEngine messagingEngine, long initTimeout = 30000)
     : base(messagingEngine, initTimeout)
 {
 }
Exemple #29
0
        private CqrsEngine CreateEngine(IComponentContext ctx, IMessagingEngine messagingEngine)
        {
            const string defaultPipeline = "commands";
            const string defaultRoute    = "self";

            var defaultRetryDelay = (long)_settings.RetryDelay.TotalMilliseconds;

            var registrations = new IRegistration[]
            {
                Register.DefaultEndpointResolver(new RabbitMqConventionEndpointResolver
                                                 (
                                                     "RabbitMq",
                                                     Messaging.Serialization.SerializationFormat.MessagePack,
                                                     environment: "lykke"
                                                 )),

                Register.BoundedContext(BlockchainWalletsBoundedContext.Name)
                .FailedCommandRetryDelay(defaultRetryDelay)

                .ListeningCommands(typeof(BeginBalanceMonitoringCommand))
                .On(defaultRoute)
                .WithCommandsHandler <BeginBalanceMonitoringCommandHandler>()

                .ListeningCommands(typeof(EndBalanceMonitoringCommand))
                .On(defaultRoute)
                .WithCommandsHandler <EndBalanceMonitoringCommandHandler>()

                .PublishingCommands(
                    typeof(BeginBalanceMonitoringCommand),
                    typeof(BeginTransactionHistoryMonitoringCommand),
                    typeof(EndBalanceMonitoringCommand),
                    typeof(EndTransactionHistoryMonitoringCommand))
                .To(BlockchainWalletsBoundedContext.Name)
                .With(defaultRoute)

                .PublishingEvents(
                    typeof(WalletArchivedEvent),
                    typeof(WalletCreatedEvent),
                    typeof(WalletDeletedEvent))
                .With(BlockchainWalletsBoundedContext.EventsRoute)

                .ProcessingOptions(defaultRoute).MultiThreaded(8).QueueCapacity(1024),

                Register.Saga <WalletSubscriptionSaga>($"{BlockchainWalletsBoundedContext.Name}.wallet-creation-saga")
                .ListeningEvents(
                    typeof(WalletCreatedEvent))
                .From(BlockchainWalletsBoundedContext.Name)
                .On(defaultRoute)
                .PublishingCommands(
                    typeof(BeginBalanceMonitoringCommand),
                    typeof(BeginTransactionHistoryMonitoringCommand))
                .To(BlockchainWalletsBoundedContext.Name)
                .With(defaultPipeline)

                .ProcessingOptions(defaultRoute).MultiThreaded(8).QueueCapacity(1024),

                Register.Saga <WalletUnsubscriptionSaga>($"{BlockchainWalletsBoundedContext.Name}.wallet-deletion-saga")
                .ListeningEvents(
                    typeof(WalletArchivedEvent),
                    typeof(WalletDeletedEvent))
                .From(BlockchainWalletsBoundedContext.Name)
                .On(defaultRoute)
                .PublishingCommands(
                    typeof(EndBalanceMonitoringCommand),
                    typeof(EndTransactionHistoryMonitoringCommand))
                .To(BlockchainWalletsBoundedContext.Name)
                .With(defaultPipeline)

                .ProcessingOptions(defaultRoute).MultiThreaded(8).QueueCapacity(1024)
            };

            return(new CqrsEngine
                   (
                       ctx.Resolve <ILogFactory>(),
                       ctx.Resolve <IDependencyResolver>(),
                       messagingEngine,
                       new DefaultEndpointProvider(),
                       true,
                       registrations));
        }