Esempio n. 1
0
        public ServiceBusListener(string functionId, EntityType entityType, string entityPath, bool isSessionsEnabled, ITriggeredFunctionExecutor triggerExecutor,
                                  ServiceBusOptions config, ServiceBusAccount serviceBusAccount, MessagingProvider messagingProvider, ILoggerFactory loggerFactory, bool singleDispatch)
        {
            _functionId              = functionId;
            _entityType              = entityType;
            _entityPath              = entityPath;
            _isSessionsEnabled       = isSessionsEnabled;
            _triggerExecutor         = triggerExecutor;
            _cancellationTokenSource = new CancellationTokenSource();
            _messagingProvider       = messagingProvider;
            _serviceBusAccount       = serviceBusAccount;
            _loggerFactory           = loggerFactory;
            _logger         = loggerFactory.CreateLogger <ServiceBusListener>();
            _batchReceiver  = CreateMessageReceiver();
            _sessionClient  = CreateSessionClient();
            _scaleMonitor   = new Lazy <ServiceBusScaleMonitor>(() => new ServiceBusScaleMonitor(_functionId, _entityType, _entityPath, _serviceBusAccount.ConnectionString, _batchReceiver, _loggerFactory));
            _singleDispatch = singleDispatch;

            if (_isSessionsEnabled)
            {
                _sessionMessageProcessor = _messagingProvider.CreateSessionMessageProcessor(_entityPath, _serviceBusAccount.ConnectionString);
            }
            else
            {
                _messageProcessor = _messagingProvider.CreateMessageProcessor(entityPath, _serviceBusAccount.ConnectionString);
            }
            _serviceBusOptions = config;
        }
        public ServiceBusListener(string entityPath, bool isSessionsEnabled, ServiceBusTriggerExecutor triggerExecutor, ServiceBusOptions config, ServiceBusAccount serviceBusAccount, MessagingProvider messagingProvider)
        {
            _entityPath              = entityPath;
            _isSessionsEnabled       = isSessionsEnabled;
            _triggerExecutor         = triggerExecutor;
            _cancellationTokenSource = new CancellationTokenSource();
            _messagingProvider       = messagingProvider;
            _serviceBusAccount       = serviceBusAccount;

            if (_isSessionsEnabled)
            {
                _sessionMessageProcessor = _messagingProvider.CreateSessionMessageProcessor(entityPath, _serviceBusAccount.ConnectionString);
            }
            else
            {
                _messageProcessor = _messagingProvider.CreateMessageProcessor(entityPath, _serviceBusAccount.ConnectionString);
            }
            _serviceBusOptions = config;
        }