/// <summary> /// Requeues the specified message. /// </summary> /// <param name="message">The message.</param> /// <param name="delayMilliseconds">Number of milliseconds to delay delivery of the message.</param> public void Requeue(Message message, int delayMilliseconds) { try { Reject(message, false); using (var client = new AmazonSQSClient(_connection.Credentials, _connection.Region)) { _logger.Value.InfoFormat("SqsMessageConsumer: requeueing the message {0}", message.Id); if (message.Header.Bag.ContainsKey("ReceiptHandle")) { message.Header.Bag.Remove("ReceiptHandle"); } var sqsMessageProducer = new SqsMessageProducer(_connection); sqsMessageProducer.Send(message); } _logger.Value.InfoFormat("SqsMessageConsumer: requeued the message {0}", message.Id); } catch (Exception exception) { _logger.Value.ErrorException("SqsMessageConsumer: Error purging queue {0}", exception, _queueName); throw; } }
/// <summary> /// Create a message producer for each publication, add it into the registry under the key of the topic /// </summary> /// <returns></returns> public IAmAProducerRegistry Create() { var producers = new Dictionary <string, IAmAMessageProducer>(); foreach (var p in _snsPublications) { var producer = new SqsMessageProducer(_connection, p); if (producer.ConfirmTopicExists()) { producers[p.Topic] = producer; } else { throw new ConfigurationException($"Missing SNS topic: {p.Topic}"); } } return(new ProducerRegistry(producers)); }