Beispiel #1
0
        public async IAsyncEnumerable <TMessage> Receive <TMessage>(int maxNumberOfMessages) where TMessage : MessageBase
        {
            if (maxNumberOfMessages < 1)
            {
                throw new ArgumentException("Max number of messages should be greater than zero.");
            }

            var queueName = _info.GetQueueName(typeof(TMessage));

            for (var i = 0; i < maxNumberOfMessages; i++)
            {
                var result = _channel.BasicGet(queueName, false);

                var message = ReceiveMessage <TMessage>(result);

                if (message == null)
                {
                    continue;
                }

                yield return(await Task.FromResult(message));
            }
        }
Beispiel #2
0
 public async Task Send <TMessage>(TMessage message) where TMessage : MessageBase
 {
     await Send(message, _queueInfo.GetQueueName(@message.GetType()));
 }
Beispiel #3
0
 public HealthCheckSqs(IAmazonSQS amazonSQS, IMessageQueueInfo info, int healthCheckInterval = 1) : base(healthCheckInterval)
 {
     _amazonSqs = amazonSQS;
     _queueUrl  = info.GetQueueName(typeof(T));
 }
Beispiel #4
0
 public HealthCheckAzureStorageQueue(CloudQueueClient cloudQueueClient, IMessageQueueInfo info, int healthCheckInterval = 1) : base(healthCheckInterval)
 {
     _cloudQueueClient = cloudQueueClient;
     _queueName        = info.GetQueueName(typeof(T));
 }
Beispiel #5
0
 public HealthCheckRabbitMq(IModel channel, IMessageQueueInfo info, int healthCheckInterval = 1) : base(healthCheckInterval)
 {
     _channel      = channel;
     _queueName    = info.GetQueueName(typeof(T));
     _exchangeName = info.GetExchangeName(typeof(T));
 }