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);
        }