예제 #1
0
        public static async Task <AdvancedAsyncProcessingWorker <T> > CreateAndStartAsync(IQueueConsumer consumer,
                                                                                          Func <IEnumerable <T>, CancellationToken, Task> batchCallbackFunc, ushort batchSize, TimeSpan processingTimeout,
                                                                                          CancellationToken cancellationToken, ExceptionHandlingStrategy exceptionHandlingStrategy = ExceptionHandlingStrategy.Requeue,
                                                                                          int invokeRetryCount = 1, int invokeRetryWaitMilliseconds = 0, ILogger logger = null)
        {
            var instance = new AdvancedAsyncProcessingWorker <T>(consumer, batchCallbackFunc, batchSize, processingTimeout,
                                                                 exceptionHandlingStrategy, invokeRetryCount, invokeRetryWaitMilliseconds, logger);

            await instance.StartAsync(cancellationToken).ConfigureAwait(false);

            return(instance);
        }
예제 #2
0
        public static async Task <AdvancedAsyncProcessingWorker <T> > CreateAndStartAsync(IQueueClient queueClient,
                                                                                          string queueName, Func <T, RabbitMQConsumerContext, CancellationToken, Task> callbackFunc, TimeSpan processingTimeout,
                                                                                          CancellationToken cancellationToken,
                                                                                          ExceptionHandlingStrategy exceptionHandlingStrategy = ExceptionHandlingStrategy.Requeue,
                                                                                          int invokeRetryCount = 1, int invokeRetryWaitMilliseconds = 0,
                                                                                          IConsumerCountManager consumerCountManager = null, IMessageRejectionHandler messageRejectionHandler = null,
                                                                                          ILogger logger = null, ushort prefetchCount = 1)
        {
            var instance = new AdvancedAsyncProcessingWorker <T>(queueClient, queueName, callbackFunc,
                                                                 processingTimeout, exceptionHandlingStrategy, invokeRetryCount, invokeRetryWaitMilliseconds,
                                                                 consumerCountManager, messageRejectionHandler, logger, prefetchCount);

            await instance.StartAsync(cancellationToken).ConfigureAwait(false);

            return(instance);
        }