コード例 #1
0
        public async Task <IListener> CreateAsync(IFunctionExecutor executor, CancellationToken cancellationToken)
        {
            // Must create all messaging entities before creating message receivers and calling OnMessage.
            // Otherwise, some function could start to execute and try to output messages to entities that don't yet
            // exist.
            await _namespaceManager.CreateTopicIfNotExistsAsync(_topicName, cancellationToken);

            await _namespaceManager.CreateSubscriptionIfNotExistsAsync(_topicName, _subscriptionName,
                                                                       cancellationToken);

            string entityPath = SubscriptionClient.FormatSubscriptionPath(_topicName, _subscriptionName);

            ITriggerExecutor <BrokeredMessage> triggerExecutor = new ServiceBusTriggerExecutor(_instanceFactory,
                                                                                               executor);

            return(new ServiceBusListener(_messagingFactory, entityPath, triggerExecutor));
        }