Exemple #1
0
        public void TestStopConsumer()
        {
            Guid consumerId = _testAdapter.StartConsumer(_testConsumerOptions, _mockConsumer);

            Assert.DoesNotThrow(() => _testAdapter.StopConsumer(consumerId, RabbitMqAdapter.DefaultOperationTimeout));
            Assert.Throws <ApplicationException>(() => _testAdapter.StopConsumer(consumerId, RabbitMqAdapter.DefaultOperationTimeout));
        }
Exemple #2
0
        public override void Start()
        {
            Logger.Info("Starting dead letter consumer");

            Guid consumerId = RabbitMqAdapter.StartConsumer(Globals.DeadLetterReprocessorOptions.DeadLetterConsumerOptions, _deadLetterQueueConsumer, true);

            do
            {
                Thread.Sleep(1000);
            } while (_deadLetterQueueConsumer.MessagesInQueue());


            Logger.Info("DLQ empty, stopping consumer");
            RabbitMqAdapter.StopConsumer(consumerId, Smi.Common.RabbitMqAdapter.DefaultOperationTimeout);

            if (_cliOptions.StoreOnly)
            {
                Logger.Debug("StoreOnly specified, stopping");
                Stop("DLQ empty");
            }
            else
            {
                Logger.Info("Republishing messages");
                _deadLetterRepublisher.RepublishMessages(_cliOptions.ReprocessFromQueue, _cliOptions.FlushMessages);

                Logger.Info("Total messages republished: " + _deadLetterRepublisher.TotalRepublished);
                Stop("Reprocess completed");
            }
        }
Exemple #3
0
        public void ResetSuite()
        {
            PurgeQueues();

            if (_rejectorId != Guid.Empty)
            {
                _testAdapter.StopConsumer(_rejectorId, RabbitMqAdapter.DefaultOperationTimeout);
            }

            MessageRejectorConsumer = new MessageRejector {
                AcceptNext = false
            };
            _rejectorId = _testAdapter.StartConsumer(_messageRejectorOptions, MessageRejectorConsumer);
        }
Exemple #4
0
        public override void Stop(string reason)
        {
            if (_consumerId != Guid.Empty)
            {
                RabbitMqAdapter.StopConsumer(_consumerId, Smi.Common.RabbitMqAdapter.DefaultOperationTimeout);
            }
            try
            {
                // Wait for any unconfirmed messages before calling stop
                _producerModel.WaitForConfirms();
            }
            catch (AlreadyClosedException)
            {
            }

            _swapper?.LogProgress(Logger, LogLevel.Info);

            base.Stop(reason);
        }