Example #1
0
        public void Configure()
        {
            _rabbitMqEndpoint.Initialize();

            var commandsExchangeName = RabbitMqExchangeNamesFactory.GetIntegrationCommandsExchangeName(_integrationName);
            var eventsExchangeName   = RabbitMqExchangeNamesFactory.GetIntegrationEventsExchangeName(_integrationName);

            _rabbitMqEndpoint.DeclareExchange(commandsExchangeName);
            _rabbitMqEndpoint.DeclareExchange(eventsExchangeName);

            var subscriptions = new MessageSubscriptionsRegistry()
                                .Handle <ReadBlockCommand>(o =>
            {
                o.WithHandler <ReadBlockCommandsHandler>();
            })
                                .AddFilter(new AppInsightTelemetryMessageFilter());

            _rabbitMqEndpoint.Subscribe(
                subscriptions,
                commandsExchangeName,
                $"bil-v2.bcn-{_integrationName}",
                messageConsumersCount: _rabbitMqSettings.MessageConsumersCount,
                messageProcessorsCount: _rabbitMqSettings.MessageProcessorsCount,
                defaultFirstLevelRetryTimeout: _rabbitMqSettings.DefaultFirstLevelRetryTimeout,
                maxFirstLevelRetryMessageAge: _rabbitMqSettings.MaxFirstLevelRetryMessageAge,
                maxFirstLevelRetryCount: _rabbitMqSettings.MaxFirstLevelRetryCount,
                firstLevelRetryQueueCapacity: _rabbitMqSettings.FirstLevelRetryQueueCapacity,
                processingQueueCapacity: _rabbitMqSettings.ProcessingQueueCapacity,
                replyExchangeName: eventsExchangeName);

            _rabbitMqEndpoint.StartListening();
        }
Example #2
0
        public void Initialize()
        {
            _endpoint.Initialize();

            foreach (var integrationName in _integrationNames)
            {
                _log.Info($"Initializing RabbitMq endpoint for the blockchain integration {integrationName}...");

                var kebabIntegrationName = integrationName.CamelToKebab();
                var commandsExchangeName = RabbitMqExchangeNamesFactory.GetIntegrationCommandsExchangeName(kebabIntegrationName);
                var eventsExchangeName   = RabbitMqExchangeNamesFactory.GetIntegrationEventsExchangeName(kebabIntegrationName);

                _endpoint.DeclareExchange(commandsExchangeName);
                _endpoint.DeclareExchange(eventsExchangeName);

                var subscriptions = new MessageSubscriptionsRegistry()
                                    .Handle <BlockHeaderReadEvent, string>(o =>
                {
                    o.WithHandler <IBlockEventsHandler>();
                    o.WithState(integrationName);
                })
                                    .Handle <BlockNotFoundEvent, string>(o =>
                {
                    o.WithHandler <IBlockEventsHandler>();
                    o.WithState(integrationName);
                })
                                    .Handle <TransferAmountTransactionsBatchEvent, string>(o =>
                {
                    o.WithHandler <IBlockEventsHandler>();
                    o.WithState(integrationName);
                })
                                    .Handle <TransferCoinsTransactionsBatchEvent, string>(o =>
                {
                    o.WithHandler <IBlockEventsHandler>();
                    o.WithState(integrationName);
                })
                                    .Handle <LastIrreversibleBlockUpdatedEvent, string>(o =>
                {
                    o.WithHandler <IBlockEventsHandler>();
                    o.WithState(integrationName);
                });

                foreach (var filter in _messageFilters)
                {
                    subscriptions.AddFilter(filter);
                }

                _endpoint.Subscribe
                (
                    subscriptions,
                    eventsExchangeName,
                    $"bil-v2.{_clientName}",
                    _defaultFirstLevelRetryTimeout,
                    _maxFirstLevelRetryMessageAge,
                    _maxFirstLevelRetryCount,
                    _firstLevelRetryQueueCapacity,
                    _processingQueueCapacity,
                    _messageConsumersCount,
                    _messageProcessorsCount
                );
            }
        }