public async void Configure( IApplicationBuilder app, ISqsClient sqsClient, ISqsConsumerService sqsConsumerService, IActorsRepository actorsRepository, IMoviesRepository moviesRepository) { app.UseSerilogRequestLogging(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapCustomHealthChecks("SqsReader service"); }); if (_appConfig.AwsQueueAutomaticallyCreate) { await sqsClient.CreateQueueAsync(); } sqsConsumerService.StartConsuming(); await actorsRepository.CreateTableAsync(); await moviesRepository.CreateTableAsync(); }
public void Configure( IApplicationBuilder app //#if (AddSqsPublisher || AddSqsConsumer) , ISqsClient sqsClient //#endif //#if (AddSqsConsumer) , ISqsConsumerService sqsConsumerService //#endif ) { //#if (AddSerilog) app.UseSerilogRequestLogging(); //#endif app.UseMiddleware <HttpExceptionMiddleware>(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); //#if (AddHealthChecks) endpoints.MapCustomHealthChecks("PROJECT_NAME service"); //#endif }); //#if (AddSqsPublisher || AddSqsConsumer) if (_appConfig.AwsSettings.AutomaticallyCreateQueue) { sqsClient.CreateQueueAsync().Wait(); } //#endif //#if (AddSqsConsumer) sqsConsumerService.StartConsuming(); //#endif }
//--- Constructors --- /// <summary> /// Constructor for creating an instance. /// </summary> /// <param name="queueName">Queue name.</param> /// <param name="client">ISqsClient instance.</param> public SqsQueueClient(SqsQueueName queueName, ISqsClient client) { if(client == null) { throw new ArgumentNullException("client"); } this.QueueName = queueName; _client = client; }
//--- Constructors --- /// <summary> /// Constructor for creating an instance. /// </summary> /// <param name="client">ISqsClient instance.</param> /// <param name="queueName">Queue name.</param> /// <param name="timerFactory">TimerFactory instance.</param> public SqsQueueDelayedSendClient(ISqsClient client, SqsQueueName queueName, TaskTimerFactory timerFactory) { if(client == null) { throw new ArgumentNullException("client"); } this.QueueName = queueName; _client = client; _timedSendAccumulator = new TimedAccumulator<KeyValuePair<int, string>>(items => AsyncUtil.ForkBackgroundSender(() => BatchSendMessages(items)), SqsUtils.MAX_NUMBER_OF_BATCH_SEND_MESSAGES, AUTOFLUSH_TIME, timerFactory); }
//--- Constructors --- /// <summary> /// Constructor for creating an instance. /// </summary> /// <param name="queueName">Queue name.</param> /// <param name="client">ISqsClient instance.</param> public SqsQueueClient(SqsQueueName queueName, ISqsClient client) { if (client == null) { throw new ArgumentNullException("client"); } this.QueueName = queueName; _client = client; }
//--- Constructors --- /// <summary> /// Constructor for creating an instance. /// </summary> /// <param name="client">ISqsClient instance.</param> /// <param name="queueName">Queue name.</param> /// <param name="timerFactory">TimerFactory instance.</param> public SqsQueueDelayedSendClient(ISqsClient client, SqsQueueName queueName, TaskTimerFactory timerFactory) { if (client == null) { throw new ArgumentNullException("client"); } this.QueueName = queueName; _client = client; _timedSendAccumulator = new TimedAccumulator <KeyValuePair <int, string> >(items => AsyncUtil.ForkBackgroundSender(() => BatchSendMessages(items)), SqsUtils.MAX_NUMBER_OF_BATCH_SEND_MESSAGES, AUTOFLUSH_TIME, timerFactory); }
public AwsSqsMessageProcessor(ISqsClient sqsClient) { if (sqsClient == null) { throw new ArgumentNullException("sqsClient"); } this.SqsClient = sqsClient; this.Log = LogManager.GetLogger(this.GetType()); }
public AwsSqsMessageFactory(ISqsClient sqsClient, AwsSqsServer mqServer, IDictionary<string, string> queueUrls) { if (sqsClient == null) throw new ArgumentNullException("sqsClient"); if (mqServer == null) throw new ArgumentNullException("mqServer"); if (queueUrls == null) throw new ArgumentNullException("queueUrls"); this.queueUrls = queueUrls; this.SqsClient = sqsClient; this.MqServer = mqServer; }
public AwsSqsMessageHandlerWorker(ISqsClient sqsClient, AwsSqsServer mqServer, IDictionary<string, string> queueUrls, IMessageHandler messageHandler, string queueName, Action<IMessageHandlerBackgroundWorker, Exception> errorHandler) : base(messageHandler, queueName, errorHandler) { if (sqsClient == null) throw new ArgumentNullException("sqsClient"); if (mqServer == null) throw new ArgumentNullException("mqServer"); if (queueUrls == null) throw new ArgumentNullException("queueUrls"); SqsClient = sqsClient; MqServer = mqServer; QueueUrls = queueUrls; }
//--- Constructors --- /// <summary> /// Constructor for creating an instance. /// </summary> /// <param name="client">ISqsClient instance.</param> /// <param name="timerFactory">TimeFactory instance.</param> public SqsDelayedSendClient(ISqsClient client, TaskTimerFactory timerFactory) { if(client == null) { throw new ArgumentNullException("client"); } if(timerFactory == null) { throw new ArgumentNullException("timerFactory"); } _client = client; _timerFactory = timerFactory; }
//--- Constructors --- /// <summary> /// Constructor for creating an instance. /// </summary> /// <param name="client">ISqsClient instance.</param> /// <param name="timerFactory">TimeFactory instance.</param> public SqsDelayedSendClient(ISqsClient client, TaskTimerFactory timerFactory) { if (client == null) { throw new ArgumentNullException("client"); } if (timerFactory == null) { throw new ArgumentNullException("timerFactory"); } _client = client; _timerFactory = timerFactory; }
private void DeleteMessagesFromQueue(ISqsClient client, IList <QueueMessage> messages) { try { foreach (var message in messages) { client.Delete(message.MessageId); } } catch (Exception) { // ugly, don't judge!!! } }
public AwsSqsServer(ISqsClient sqsClient, int retryCount = DefaultRetryCount, TimeSpan?requestTimeOut = null, decimal maxNumberOfMessagesToReceivePerRequest = 10, decimal messageVisibilityTimeoutInSeconds = 30) : base(null, retryCount) //// Default to use Long Polling { if (sqsClient == null) { throw new ArgumentNullException("sqsClient"); } this.SqsClient = sqsClient; this.RequestTimeOut = requestTimeOut.HasValue ? requestTimeOut.Value : TimeSpan.FromSeconds(20); this.MaxNumberOfMessagesToReceivePerRequest = maxNumberOfMessagesToReceivePerRequest; this.MessageVisibilityTimeoutInSeconds = messageVisibilityTimeoutInSeconds; this.QueueUrls = new Dictionary <string, string>(); }
public AwsSqsMessageProducer(ISqsClient sqsClient, IDictionary <string, string> queueUrls, Action onPublishedCallback) : base(onPublishedCallback) { if (sqsClient == null) { throw new ArgumentNullException("sqsClient"); } if (queueUrls == null) { throw new ArgumentNullException("queueUrls"); } this.SqsClient = sqsClient; this.QueueUrls = queueUrls; }
public async void Configure(IApplicationBuilder app, ISqsClient sqsClient) { app.UseSerilogRequestLogging(); app.UseMiddleware <HttpExceptionMiddleware>(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapCustomHealthChecks("SqsWriter service"); }); if (_appConfig.AwsQueueAutomaticallyCreate) { await sqsClient.CreateQueueAsync(); } }
public AwsSqsQueueHandlerWorker( ISqsClient sqsClient, // IMessageCoordinator messageCoordinator, AwsSqsServer sqsServer, Type messageType, string queueName, string queueUrl, Action <IQueueHandlerBackgroundWorker, Exception> errorHandler, int waitTimeInSeconds, decimal maxNumberOfMessages, decimal messageVisibilityTimeout) : base(queueName, errorHandler) { if (sqsClient == null) { throw new ArgumentNullException("sqsClient"); } if (sqsServer == null) { throw new ArgumentNullException("sqsServer"); } // if (messageCoordinator == null) throw new ArgumentNullException("messageCoordinator"); if (messageType == null) { throw new ArgumentNullException("messageType"); } if (waitTimeInSeconds > 20) { throw new ArgumentException("WaitTimeInSeconds must be a value between 0 and 20 seconds.", "waitTimeInSeconds"); } if (maxNumberOfMessages < 1) { throw new ArgumentException("MaxNumberOfMessages must be a minimum value of 1.", "maxNumberOfMessages"); } this.SqsClient = sqsClient; this.MqServer = sqsServer; this.MessageCoordinator = sqsServer; // messageCoordinator; this.MessageType = messageType; this.QueueName = queueName; // queue.Key; this.QueueUrl = queueUrl; // queue.Value; this.WaitTimeInSeconds = waitTimeInSeconds; this.MaxNumberOfMessages = maxNumberOfMessages; this.MessageVisibilityTimeout = messageVisibilityTimeout; }
public AwsSqsMessageFactory(ISqsClient sqsClient, AwsSqsServer mqServer, IDictionary <string, string> queueUrls) { if (sqsClient == null) { throw new ArgumentNullException("sqsClient"); } if (mqServer == null) { throw new ArgumentNullException("mqServer"); } if (queueUrls == null) { throw new ArgumentNullException("queueUrls"); } this.queueUrls = queueUrls; this.SqsClient = sqsClient; this.MqServer = mqServer; }
public AwsSqsMessageHandlerWorker(ISqsClient sqsClient, AwsSqsServer mqServer, IDictionary <string, string> queueUrls, IMessageHandler messageHandler, string queueName, Action <IMessageHandlerBackgroundWorker, Exception> errorHandler) : base(messageHandler, queueName, errorHandler) { if (sqsClient == null) { throw new ArgumentNullException("sqsClient"); } if (mqServer == null) { throw new ArgumentNullException("mqServer"); } if (queueUrls == null) { throw new ArgumentNullException("queueUrls"); } SqsClient = sqsClient; MqServer = mqServer; QueueUrls = queueUrls; }
public AwsSqsMessageQueueClient(ISqsClient sqsClient, IMessageCoordinator messageCoordinator, IDictionary <string, string> queueNames, Action onPublishedCallback) : base(onPublishedCallback) { if (sqsClient == null) { throw new ArgumentNullException("sqsClient"); } if (messageCoordinator == null) { throw new ArgumentNullException("messageCoordinator"); } if (queueNames == null) { throw new ArgumentNullException("queueNames"); } this.SqsClient = sqsClient; this.MessageCoordinator = messageCoordinator; this.QueueNames = queueNames; }
public AwsSqsQueueHandlerWorker( ISqsClient sqsClient, // IMessageCoordinator messageCoordinator, AwsSqsServer sqsServer, Type messageType, string queueName, string queueUrl, Action<IQueueHandlerBackgroundWorker, Exception> errorHandler, int waitTimeInSeconds, decimal maxNumberOfMessages, decimal messageVisibilityTimeout) : base(queueName, errorHandler) { if (sqsClient == null) throw new ArgumentNullException("sqsClient"); if (sqsServer == null) throw new ArgumentNullException("sqsServer"); // if (messageCoordinator == null) throw new ArgumentNullException("messageCoordinator"); if (messageType == null) throw new ArgumentNullException("messageType"); if (waitTimeInSeconds > 20) { throw new ArgumentException("WaitTimeInSeconds must be a value between 0 and 20 seconds.", "waitTimeInSeconds"); } if (maxNumberOfMessages < 1) { throw new ArgumentException("MaxNumberOfMessages must be a minimum value of 1.", "maxNumberOfMessages"); } this.SqsClient = sqsClient; this.MqServer = sqsServer; this.MessageCoordinator = sqsServer; // messageCoordinator; this.MessageType = messageType; this.QueueName = queueName; // queue.Key; this.QueueUrl = queueUrl; // queue.Value; this.WaitTimeInSeconds = waitTimeInSeconds; this.MaxNumberOfMessages = maxNumberOfMessages; this.MessageVisibilityTimeout = messageVisibilityTimeout; }
//--- Constructors --- /// <summary> /// Constructor for creating an instance. /// </summary> /// <param name="client">ISqsClient to use.</param> public SqsPollingClient(ISqsClient client) { _client = client; }
public SendController(ISqsClient sqsClient) { _sqsClient = sqsClient; }
public SqsHealthCheck(ISqsClient sqsClient) { _sqsClient = sqsClient; }
public SqsConsumerService(ISqsClient sqsClient, IEnumerable <IMessageProcessor> messageProcessors, ILogger <SqsConsumerService> logger) { _sqsClient = sqsClient; _messageProcessors = messageProcessors; _logger = logger; }
public SendUpdateUserConnectionListMessageCommandHandler(ISqsClient sqsClient) { _sqsClient = sqsClient; }
public PublishController(ISqsClient sqsClient, ILogger <PublishController> logger) { _sqsClient = sqsClient; _logger = logger; }
public PublishController(ISqsClient sqsClient) { _sqsClient = sqsClient; }