public void StartEventReplay_ShouldSendCommands()
        {
            _channelMock.Setup(chan => chan.QueueDelete(It.IsAny <string>(), false, false)).Returns(1);

            _nijnContext.CommandBus.DeclareCommandQueue(NameConstants.AuditlogQueue);
            _target.StartEventReplay();

            _connectionMock.VerifyAll();
            _channelMock.Verify(chan => chan.QueueDelete(It.IsAny <string>(), false, false), Times.Exactly(2));

            var queue = _nijnContext.CommandBus.Queues[NameConstants.AuditlogQueue];

            Assert.AreEqual(2, queue.MessageQueueLength);

            var command1 = queue[0].Command;
            var json1    = JObject.Parse(command1.Message);

            Assert.AreEqual(NameConstants.AuditlogQueue, command1.RoutingKey);
            Assert.AreEqual(NameConstants.AuditlogReplayCommandType, command1.Type);
            Assert.AreEqual(NameConstants.BffWebshopEventReplayExchange, json1["ExchangeName"]);
            Assert.AreEqual(NameConstants.CatalogusServiceCategorieAanCatalogusToegevoegdEvent, json1["Topic"]);

            var command2 = queue[1].Command;
            var json2    = JObject.Parse(command2.Message);

            Assert.AreEqual(NameConstants.AuditlogQueue, command2.RoutingKey);
            Assert.AreEqual(NameConstants.AuditlogReplayCommandType, command2.Type);
            Assert.AreEqual(NameConstants.BffWebshopEventReplayExchange, json2["ExchangeName"]);
            Assert.AreEqual(NameConstants.MagazijnServiceVoorraadChangedEvent, json2["Topic"]);
        }
        public void StartEventReplay_ShouldRegisterListenersToTheExchange()
        {
            _target.StartEventReplay();

            _channelMock.VerifyAll();
            _connectionMock.VerifyAll();

            var replayEventQueue = _nijnContext.EventBus.Queues[NameConstants.BestelServiceEventReplayQueue];

            Assert.IsNotNull(replayEventQueue, "ReplayEventQueue should be declared");
            Assert.IsTrue(replayEventQueue.TopicExpressions.Contains(NameConstants.CatalogusServiceCategorieAanCatalogusToegevoegdEvent));
        }
        private void ConfigureReplayEvents(IServiceCollection services)
        {
            var contextBuilder = new RabbitMQContextBuilder()
                                 .SetLoggerFactory(_loggerFactory)
                                 .WithConnectionTimeout(5000)
                                 .ReadFromEnvironmentVariables()
                                 .WithExchange(NameConstants.BffWebshopEventReplayExchange);

            using (var context = contextBuilder.CreateContext())
                using (var replayService = new EventReplayService(context, services, 5000))
                {
                    replayService.StartEventReplay();
                }
        }
Exemple #4
0
        private void StartEventReplay()
        {
            var timeout = 5000;

            var connectionBuilder = new RabbitMQContextBuilder()
                                    .SetLoggerFactory(_loggerFactory)
                                    .WithConnectionTimeout(timeout)
                                    .ReadFromEnvironmentVariables()
                                    .WithExchange(NameConstants.BestelServiceEventReplayExchange);

            using (var context = connectionBuilder.CreateContext())
                using (var replayService = new EventReplayService(context, _services, timeout))
                {
                    replayService.StartEventReplay();
                }
        }