Esempio n. 1
0
        public async Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context)
        {
            var attr = context.Parameter.GetCustomAttribute <QueueBatchTriggerAttribute>();

            if (attr == null)
            {
                return(null);
            }

            var queueName = attr.QueueName;

            var messageQueue = provider.GetClient().GetQueueReference(queueName);
            var poisonQueue  = CreatePoisonQueue(queueName);

            await Task.WhenAll(
                messageQueue.CreateIfNotExistsAsync(),
                poisonQueue.CreateIfNotExistsAsync()
                ).ConfigureAwait(false);

            var cache = new HttpMessageHandlerExpiringCache(TimeSpan.FromSeconds(10));

            var queue = attr.UseFasterQueues
                ? new QueueFunctionLogic(SdkQueue.CreateFast(messageQueue, cache), SdkQueue.CreateFast(poisonQueue, cache))
                : new QueueFunctionLogic(new SdkQueue(messageQueue), new SdkQueue(poisonQueue));

            return(new TriggerBinding(context.Parameter, queue, TimeSpan.FromSeconds(attr.MaxBackOffInSeconds), attr.ParallelGets, attr.RunWithEmptyBatch, loggerFactory));
        }
Esempio n. 2
0
        public async Task SetUp()
        {
            var queues = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudQueueClient();

            var test = TestContext.CurrentContext.Test;

            var queueName = test.MethodName.Replace("_", "").ToLower();
            var fast = queues.GetQueueReference(queueName + "1");
            var sdk = queues.GetQueueReference(queueName + "2");

            await Task.WhenAll(fast.CreateIfNotExistsAsync(), sdk.CreateIfNotExistsAsync());

            toClear.Add(fast);
            toClear.Add(sdk);

            sdkQueue = new SdkQueue(sdk);
            fastQueue = SdkQueue.CreateFast(fast, Cache);
        }