public void ShouldProperlyThrowExceptionWhenThereAreNoProductionExchanges() { var consumptionExchange = new RabbitMqExchange("exchange", ClientExchangeType.Consumption, new RabbitMqExchangeOptions()); var service = CreateService(new[] { consumptionExchange }); Assert.Throws <ArgumentException>(() => service.ValidateArguments("another.exchange", "routing.key")); }
public void ShouldProperlyValidateWhenThereIsUiversalExchange() { const string exchangeName = "exchange"; var consumptionExchange = new RabbitMqExchange(exchangeName, ClientExchangeType.Universal, new RabbitMqExchangeOptions()); var service = CreateService(new[] { consumptionExchange }); service.ValidateArguments(exchangeName, "routing.key"); }
public void ShouldProperlyThrowExceptionWhenThereIsAnExchangeWithSameNameButWithConsumptionType() { const string exchangeName = "exchange"; var consumptionExchange = new RabbitMqExchange(exchangeName, ClientExchangeType.Consumption, new RabbitMqExchangeOptions()); var service = CreateService(new[] { consumptionExchange }); Assert.Throws <ArgumentException>(() => service.ValidateArguments(exchangeName, "routing.key")); }
protected SubscriberBase(DipsConfiguration configuration, ILogger logger, RabbitMqConsumer consumer, RabbitMqExchange invalidExchange, string invalidRoutingKey, string recoverableRoutingKey) { Log = logger; Configuration = configuration; Consumer = consumer; InvalidExchange = invalidExchange; InvalidRoutingKey = invalidRoutingKey; RecoverableRoutingKey = recoverableRoutingKey; }
public CorrectCodelineRequestSubscriber(DipsConfiguration configuration, ILogger logger, RabbitMqConsumer consumer, RabbitMqExchange invalidExchange, string invalidRoutingKey, string recoverableRoutingKey) : base(configuration, logger, consumer, invalidExchange, invalidRoutingKey, recoverableRoutingKey) { var helper = new BatchCodelineRequestMapHelper(new DateTimeProvider(), Configuration); QueueMapper = new CorrectBatchCodelineRequestToDipsQueueMapper(helper); VoucherMapper = new CorrectBatchCodelineRequestToDipsNabChqScanPodMapper(helper); DbIndexMapper = new CorrectBatchCodelineRequestToDipsDbIndexMapper(helper); }
private static void StartExchangePassive(IModel channel, RabbitMqExchange exchange) { channel.ExchangeDeclarePassive(exchange: exchange.Name); foreach (var queue in exchange.Options.Queues) { if (queue.PassiveMode) { StartQueuePassive(channel, queue); continue; } StartQueue(channel, queue, exchange.Name); } }
private static void StartExchange(IModel channel, RabbitMqExchange exchange) { channel.ExchangeDeclare( exchange: exchange.Name, type: exchange.Options.Type, durable: exchange.Options.Durable, autoDelete: exchange.Options.AutoDelete, arguments: exchange.Options.Arguments); foreach (var queue in exchange.Options.Queues) { StartQueue(channel, queue, exchange.Name); } }
private void InitializeQueueConnection() { var invalidExchange = Configuration.InvalidExchangeName; var hostNames = Configuration.HostName; var userName = Configuration.UserName; var password = Configuration.Password; var timeout = Configuration.Timeout; var heartbeat = Configuration.HeartbeatSeconds; InvalidRoutingKey = Configuration.InvalidRoutingKey; RecoverableRoutingKey = Configuration.RecoverableRoutingKey; PollingIntervalSecs = Configuration.PollingIntervalSecs; Consumer = new RabbitMqConsumer(ConsumerName, hostNames, userName, password, timeout, heartbeat); Exchange = new RabbitMqExchange(ExchangeName, hostNames, userName, password, timeout, heartbeat); InvalidExchange = new RabbitMqExchange(invalidExchange, hostNames, userName, password, timeout, heartbeat); }
public async Task ShouldProperlyConsumeMessagesButWithoutAutoAck(int numberOfMessages) { var channelMock = new Mock <IModel>(); var connectionMock = new Mock <IConnection>(); var consumer = new AsyncEventingBasicConsumer(channelMock.Object); var messageHandlingPipelineExecutingServiceMock = new Mock <IMessageHandlingPipelineExecutingService>(); const string exchangeName = "exchange"; var exchange = new RabbitMqExchange(exchangeName, ClientExchangeType.Consumption, new RabbitMqExchangeOptions { DisableAutoAck = true }); var consumingService = CreateConsumingService(messageHandlingPipelineExecutingServiceMock.Object, new[] { exchange }); consumingService.UseConnection(connectionMock.Object); consumingService.UseChannel(channelMock.Object); consumingService.UseConsumer(consumer); await consumer.HandleBasicDeliver( "1", 0, false, exchangeName, "routing,key", null, new ReadOnlyMemory <byte>()); messageHandlingPipelineExecutingServiceMock.Verify(x => x.Execute(It.IsAny <MessageHandlingContext>()), Times.Never); consumingService.StartConsuming(); for (var i = 1; i <= numberOfMessages; i++) { await consumer.HandleBasicDeliver( "1", (ulong)numberOfMessages, false, "exchange", "routing,key", null, new ReadOnlyMemory <byte>()); } messageHandlingPipelineExecutingServiceMock.Verify(x => x.Execute(It.IsAny <MessageHandlingContext>()), Times.Exactly(numberOfMessages)); }
private void InitializeQueueConnection() { log.Debug("CarService: InitializeQueueConnection"); var hostName = ConfigurationManager.AppSettings["queue:HostName"]; var userName = ConfigurationManager.AppSettings["queue:UserName"]; var password = ConfigurationManager.AppSettings["queue:Password"]; var queueTimeout = int.Parse(ConfigurationManager.AppSettings["queue:Timeout"]); var heartbeatSeconds = int.Parse(ConfigurationManager.AppSettings["queue:HeartbeatSeconds"]); var inboundQueueName = ConfigurationManager.AppSettings["adapter:InboundQueueName"]; var outboundExchangeName = ConfigurationManager.AppSettings["adapter:OutboundExchangeName"]; var invalidQueueName = ConfigurationManager.AppSettings["adapter:InvalidQueueName"]; var automaticRecoveryEnabled = bool.Parse(ConfigurationManager.AppSettings["queue:AutomaticRecoveryEnabled"]); consumer = new RabbitMqConsumer(inboundQueueName, hostName, userName, password, queueTimeout, heartbeatSeconds, automaticRecoveryEnabled); exchange = new RabbitMqExchange(outboundExchangeName, hostName, userName, password, queueTimeout, heartbeatSeconds, automaticRecoveryEnabled); invalidExchange = new RabbitMqExchange(invalidQueueName, hostName, userName, password, queueTimeout, heartbeatSeconds, automaticRecoveryEnabled); consumer.ConnectionLost += Connection_ConnectionShutdown; consumer.ConsumerFailed += Consumer_ConsumerFailed; ProcessingService.Consumer = consumer; ProcessingService.Exchange = exchange; ProcessingService.InvalidExchange = invalidExchange; }
public GenerateCorrespondingVoucherResponsePollingJob(IAdapterConfiguration configuration, ILogger log, RabbitMqExchange exchange) : base(configuration, log, exchange) { }
protected PollingJob(IAdapterConfiguration configuration, ILogger log, RabbitMqExchange exchange) { Configuration = configuration; Log = log; Exchange = exchange; }
public GetVouchersInformationRequestPollingJob(IAdapterConfiguration configuration, ILogger log, RabbitMqExchange exchange) : base(configuration, log, exchange) { }
public CheckThirdPartyResponsePollingJob(IAdapterConfiguration configuration, ILogger log, RabbitMqExchange exchange) : base(configuration, log, exchange) { }
public CorrectTransactionResponsePollingJob(IAdapterConfiguration configuration, ILogger log, RabbitMqExchange exchange) : base(configuration, log, exchange) { }
public ValidateCodelineResponsePollingJob(IAdapterConfiguration configuration, ILogger log, RabbitMqExchange exchange) : base(configuration, log, exchange) { }
public GetVouchersInformationResponseSubscriber(DipsConfiguration configuration, ILogger logger, RabbitMqConsumer consumer, RabbitMqExchange invalidExchange, string invalidRoutingKey, string recoverableRoutingKey) : base(configuration, logger, consumer, invalidExchange, invalidRoutingKey, recoverableRoutingKey) { }