Пример #1
0
        public SQLMessageQueue(IDbConnectionProvider connectionProvider, ISQLDialect dialect, QueueName queueName,
            IQueueListener listener, QueueOptions options = default(QueueOptions))
        {
            if (connectionProvider == null) throw new ArgumentNullException("connectionProvider");
            if (dialect == null) throw new ArgumentNullException("dialect");
            if (queueName == null) throw new ArgumentNullException("queueName");
            if (listener == null) throw new ArgumentNullException("listener");

            _connectionProvider = connectionProvider;
            _dialect = dialect;
            _queueName = queueName;

            _listener = listener;
            _autoAcknowledge = options.AutoAcknowledge;
            _maxAttempts = options.MaxAttempts <= 0 ? 10 : options.MaxAttempts;
            _retryDelay = options.RetryDelay < TimeSpan.Zero ? TimeSpan.Zero : options.RetryDelay;

            var concurrencyLimit = options.ConcurrencyLimit <= 0
                ? QueueOptions.DefaultConcurrencyLimit
                : options.ConcurrencyLimit;
            _concurrentMessageProcessingSlot = new SemaphoreSlim(concurrencyLimit);

            _cancellationTokenSource = new CancellationTokenSource();
            _queuedMessages = new BufferBlock<SQLQueuedMessage>(new DataflowBlockOptions
            {
                CancellationToken = _cancellationTokenSource.Token
            });
        }
Пример #2
0
        /// <inheritdoc />
        /// <summary>
        /// Initializes a new <see cref="T:Platibus.MongoDB.MongoDBMessageQueue" /> with the specified values
        /// </summary>
        /// <param name="queueName">The name of the queue</param>
        /// <param name="listener">The object that will be notified when messages are
        ///     added to the queue</param>
        /// <param name="options">(Optional) Settings that influence how the queue behaves</param>
        /// <param name="diagnosticService"></param>
        /// <param name="database">The MongoDB database</param>
        /// <param name="collectionName">(Optional) The name of the collection in which the
        ///     queued messages should be stored.  If omitted, the queue name will be used.</param>
        /// <param name="securityTokenService"></param>
        /// <param name="messageEncryptionService">(Optional) The message encryption service used
        /// to encrypt persistent messages at rest</param>
        /// <exception cref="T:System.ArgumentNullException">
        /// Thrown if <paramref name="database" />, <paramref name="queueName" />, or
        /// <paramref name="listener" /> are <c>null</c>
        /// </exception>
        public MongoDBMessageQueue(QueueName queueName, IQueueListener listener, QueueOptions options,
                                   IDiagnosticService diagnosticService, IMongoDatabase database, string collectionName,
                                   ISecurityTokenService securityTokenService, IMessageEncryptionService messageEncryptionService)
            : base(queueName, listener, options, diagnosticService)
        {
            if (database == null)
            {
                throw new ArgumentNullException(nameof(database));
            }
            if (queueName == null)
            {
                throw new ArgumentNullException(nameof(queueName));
            }
            if (listener == null)
            {
                throw new ArgumentNullException(nameof(listener));
            }

            _securityTokenService     = securityTokenService ?? throw new ArgumentNullException(nameof(securityTokenService));
            _messageEncryptionService = messageEncryptionService;

            var myCollectionName = string.IsNullOrWhiteSpace(collectionName)
                ? MapToCollectionName(queueName)
                : collectionName;

            _queuedMessages          = database.GetCollection <QueuedMessageDocument>(myCollectionName);
            MessageEnqueued         += OnMessageEnqueued;
            MessageAcknowledged     += OnMessageAcknowledged;
            AcknowledgementFailure  += OnAcknowledgementFailure;
            MaximumAttemptsExceeded += OnMaximumAttemptsExceeded;
        }
Пример #3
0
        public FilesystemMessageQueue(DirectoryInfo directory, IQueueListener listener,
            QueueOptions options = default(QueueOptions))
        {
            if (directory == null) throw new ArgumentNullException("directory");
            if (listener == null) throw new ArgumentNullException("listener");

            _directory = directory;
            _deadLetterDirectory = new DirectoryInfo(Path.Combine(directory.FullName, "dead"));

            _listener = listener;
            _autoAcknowledge = options.AutoAcknowledge;
            _maxAttempts = options.MaxAttempts <= 0 ? 10 : options.MaxAttempts;
            _retryDelay = options.RetryDelay < TimeSpan.Zero ? TimeSpan.Zero : options.RetryDelay;

            var concurrencyLimit = options.ConcurrencyLimit <= 0
                ? QueueOptions.DefaultConcurrencyLimit
                : options.ConcurrencyLimit;
            _concurrentMessageProcessingSlot = new SemaphoreSlim(concurrencyLimit);

            _cancellationTokenSource = new CancellationTokenSource();
            _queuedMessages = new BufferBlock<MessageFile>(new DataflowBlockOptions
            {
                CancellationToken = _cancellationTokenSource.Token
            });
        }
Пример #4
0
        /// <inheritdoc />
        /// <summary>
        /// Initializes a new <see cref="T:Platibus.SQL.SQLMessageQueue" /> with the specified values
        /// </summary>
        /// <param name="queueName">The name of the queue</param>
        /// <param name="listener">The object that will be notified when messages are
        ///     added to the queue</param>
        /// <param name="options">(Optional) Settings that influence how the queue behaves</param>
        /// <param name="diagnosticService">(Optional) The service through which diagnostic events
        ///     are reported and processed</param>
        /// <param name="connectionProvider">The database connection provider</param>
        /// <param name="commandBuilders">A collection of factories capable of
        ///     generating database commands for manipulating queued messages that conform to the SQL
        ///     syntax required by the underlying connection provider</param>
        /// <param name="securityTokenService">(Optional) The message security token
        ///     service to use to issue and validate security tokens for persisted messages.</param>
        /// <param name="messageEncryptionService"></param>
        /// <exception cref="T:System.ArgumentNullException">Thrown if <paramref name="connectionProvider" />,
        /// <paramref name="commandBuilders" />, <paramref name="queueName" />, or <paramref name="listener" />
        /// are <c>null</c></exception>
        public SQLMessageQueue(QueueName queueName,
                               IQueueListener listener,
                               QueueOptions options, IDiagnosticService diagnosticService, IDbConnectionProvider connectionProvider,
                               IMessageQueueingCommandBuilders commandBuilders, ISecurityTokenService securityTokenService,
                               IMessageEncryptionService messageEncryptionService)
            : base(queueName, listener, options, diagnosticService)
        {
            if (queueName == null)
            {
                throw new ArgumentNullException(nameof(queueName));
            }
            if (listener == null)
            {
                throw new ArgumentNullException(nameof(listener));
            }

            ConnectionProvider       = connectionProvider ?? throw new ArgumentNullException(nameof(connectionProvider));
            CommandBuilders          = commandBuilders ?? throw new ArgumentNullException(nameof(commandBuilders));
            MessageEncryptionService = messageEncryptionService;
            SecurityTokenService     = securityTokenService ?? throw new ArgumentNullException(nameof(securityTokenService));

            MessageEnqueued         += OnMessageEnqueued;
            MessageAcknowledged     += OnMessageAcknowledged;
            AcknowledgementFailure  += OnAcknowledgementFailure;
            MaximumAttemptsExceeded += OnMaximumAttemptsExceeded;
        }
Пример #5
0
        public RabbitMQQueue(QueueName queueName, IQueueListener listener, IConnection connection,
            Encoding encoding = null, QueueOptions options = default(QueueOptions))
        {
            if (queueName == null) throw new ArgumentNullException("queueName");
            if (listener == null) throw new ArgumentNullException("listener");
            if (connection == null) throw new ArgumentNullException("connection");

            _queueName = queueName;
            _queueExchange = _queueName.GetExchangeName();
            _retryQueueName = queueName.GetRetryQueueName();
            _retryExchange = _queueName.GetRetryExchangeName();
            _deadLetterExchange = _queueName.GetDeadLetterExchangeName();

            _listener = listener;
            _connection = connection;
            _encoding = encoding ?? Encoding.UTF8;
            _ttl = options.TTL;
            _maxAttempts = Math.Max(options.MaxAttempts, 1);
            _retryDelay = options.RetryDelay < TimeSpan.Zero ? TimeSpan.Zero : options.RetryDelay;
            _cancellationTokenSource = new CancellationTokenSource();

            var autoAcknowledge = options.AutoAcknowledge;
            var concurrencyLimit = Math.Max(options.ConcurrencyLimit, 1);
            _consumers = new DurableConsumer[concurrencyLimit];
            for (var i = 0; i < _consumers.Length; i++)
            {
                var consumerTag = _queueName + "_" + i;
                _consumers[i] = new DurableConsumer(_connection, queueName, HandleDelivery, consumerTag,
                    autoAcknowledge);
            }
        }
        /// <inheritdoc />
        public Task CreateQueue(QueueName queueName, IQueueListener listener, QueueOptions options = null,
                                CancellationToken cancellationToken = default(CancellationToken))
        {
            var myOptions = options ?? new QueueOptions();

            _virtualQueues.GetOrAdd(queueName, new VirtualQueue(listener, myOptions.AutoAcknowledge));
            return(Task.FromResult(0));
        }
 public Task CreateQueue(QueueName queueName, IQueueListener listener, QueueOptions options = default(QueueOptions), CancellationToken cancellationToken = default(CancellationToken))
 {
     if (!_queues.TryAdd(queueName, new InMemoryQueue(listener, options)))
     {
         throw new QueueAlreadyExistsException(queueName);
     }
     return Task.FromResult(true);
 }
 internal BrokerLauncherCloudQueueWatcher(IBrokerLauncher instance, IQueueListener <CloudQueueCmdDto> listener, IQueueWriter <CloudQueueResponseDto> writer)
 {
     this.instance      = instance;
     this.QueueListener = listener;
     this.QueueWriter   = writer;
     this.QueueListener.MessageReceivedCallback = this.InvokeInstanceMethodFromCmdObj;
     this.RegisterCmdDelegates();
 }
Пример #9
0
 /// <inheritdoc />
 /// <summary>
 /// Initializes a new <see cref="T:Platibus.SQLite.SQLiteMessageQueue" />
 /// </summary>
 /// <param name="queueName">The name of the queue</param>
 /// <param name="listener">The object that will process messages off of the queue</param>
 /// <param name="options">(Optional) Options for concurrency and retry limits</param>
 /// <param name="diagnosticService">(Optional) The service through which diagnostic events
 ///     are reported and processed</param>
 /// <param name="baseDirectory">The directory in which the SQLite database will be created</param>
 /// <param name="securityTokenService">(Optional) A service for issuing security tokens
 ///     that can be stored with queued messages to preserve the security context in which
 ///     they were enqueued</param>
 /// <param name="messageEncryptionService"></param>
 public SQLiteMessageQueue(QueueName queueName,
                           IQueueListener listener,
                           QueueOptions options, IDiagnosticService diagnosticService, DirectoryInfo baseDirectory,
                           ISecurityTokenService securityTokenService, IMessageEncryptionService messageEncryptionService)
     : base(queueName, listener, options, diagnosticService, InitConnectionProvider(baseDirectory, queueName, diagnosticService),
            new SQLiteMessageQueueingCommandBuilders(), securityTokenService, messageEncryptionService)
 {
     _cancellationTokenSource = new CancellationTokenSource();
 }
Пример #10
0
        /// <inheritdoc />
        public async Task CreateQueue(QueueName queueName, IQueueListener listener, QueueOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var queue = await InternalCreateQueue(queueName, listener, options, cancellationToken);

            if (!_queues.TryAdd(queueName, queue))
            {
                throw new QueueAlreadyExistsException(queueName);
            }
            await queue.Init(cancellationToken);
        }
Пример #11
0
        public async Task CreateQueue(QueueName queueName, IQueueListener listener, QueueOptions options = default(QueueOptions), CancellationToken cancellationToken = default(CancellationToken))
        {
            var queue = new SQLMessageQueue(_connectionProvider, _dialect, queueName, listener, options);
            if (!_queues.TryAdd(queueName, queue))
            {
                throw new QueueAlreadyExistsException(queueName);
            }

            Log.DebugFormat("Initializing SQL queue named \"{0}\"...", queueName);
            await queue.Init();
            Log.DebugFormat("SQL queue \"{0}\" created successfully", queueName);
        }
        public async Task CreateQueue(QueueName queueName, IQueueListener listener, QueueOptions options = default(QueueOptions), CancellationToken cancellationToken = default(CancellationToken))
        {
            CheckDisposed();
            var queue = new SQLiteMessageQueue(_baseDirectory, queueName, listener, options);
            if (!_queues.TryAdd(queueName, queue))
            {
                throw new QueueAlreadyExistsException(queueName);
            }

            await queue.Init();
            Log.DebugFormat("SQLite queue \"{0}\" created successfully", queueName);
        }
Пример #13
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                Stop();

                if (_queueListener != null)
                {
                    _queueListener.Dispose();
                    _queueListener = null;
                }
            }
        }
Пример #14
0
 public SQLiteMessageQueue(DirectoryInfo baseDirectory, QueueName queueName, IQueueListener listener,
     QueueOptions options = default(QueueOptions))
     : base(InitDb(baseDirectory, queueName), new SQLiteDialect(), queueName, listener, options)
 {
     _cancellationTokenSource = new CancellationTokenSource();
     _operationQueue = new ActionBlock<ISQLiteOperation>(
         op => op.Execute(),
         new ExecutionDataflowBlockOptions
         {
             CancellationToken = _cancellationTokenSource.Token,
             MaxDegreeOfParallelism = 1
         });
 }
Пример #15
0
        public InMemoryQueue(IQueueListener listener, QueueOptions options = default(QueueOptions))
        {
            if (listener == null) throw new ArgumentNullException("listener");

            _listener = listener;
            _autoAcknowledge = options.AutoAcknowledge;
            _maxAttempts = options.MaxAttempts <= 0 ? int.MaxValue : options.MaxAttempts;
            _retryDelay = options.RetryDelay < TimeSpan.Zero ? TimeSpan.Zero : options.RetryDelay;

            var concurrencyLimit = options.ConcurrencyLimit <= 0
                ? QueueOptions.DefaultConcurrencyLimit
                : options.ConcurrencyLimit;
            _concurrentMessageProcessingSlot = new SemaphoreSlim(concurrencyLimit);
        }
Пример #16
0
        public LocalStorageJobHost(
            IQueueTriggerIndexer queueTriggerIndexer = null,
            IQueueListener queueListener             = null,
            ITraceWriter tracerWriter = null,
            IQueueTriggerMethodInvoker queueMethodInvoker = null
            )
        {
            _stoppingTokenSource = new CancellationTokenSource();

            _tracerWriter        = tracerWriter ?? new LocalTraceWriter(System.Diagnostics.TraceLevel.Info);
            _queueTriggerIndexer = queueTriggerIndexer ?? new QueueTriggerIndexer(_tracerWriter);
            _queueMethodInvoker  = queueMethodInvoker ?? new QueueTriggerMethodInvoker();
            _queueListener       = queueListener ?? new LocalQueueListener(_tracerWriter, _queueMethodInvoker);
        }
        /// <inheritdoc />
        /// <summary>
        /// Establishes a named queue
        /// </summary>
        /// <param name="queueName">The name of the queue</param>
        /// <param name="listener">An object that will receive messages off of the queue for processing</param>
        /// <param name="options">(Optional) Options that govern how the queue behaves</param>
        /// <param name="cancellationToken">(Optional) A cancellation token that can be used
        /// by the caller to cancel queue creation if necessary</param>
        /// <returns>Returns a task that will complete when the queue has been created</returns>
        /// <exception cref="T:System.ArgumentNullException">Thrown if <paramref name="queueName" /> or
        /// <paramref name="listener" /> is <c>null</c></exception>
        /// <exception cref="T:Platibus.QueueAlreadyExistsException">Thrown if a queue with the specified
        /// name already exists</exception>
        public Task CreateQueue(QueueName queueName, IQueueListener listener, QueueOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            CheckDisposed();
            var connection = _connectionManager.GetConnection(_uri);
            var queue      = new RabbitMQQueue(connection, queueName,
                                               listener, _encoding, options ?? _defaultQueueOptions, _diagnosticService, _securityTokenService, _messageEncryptionService);

            if (!_queues.TryAdd(queueName, queue))
            {
                throw new QueueAlreadyExistsException(queueName);
            }

            queue.Init();
            return(Task.FromResult(true));
        }
        public async Task CreateQueue(QueueName queueName, IQueueListener listener, QueueOptions options = default(QueueOptions), CancellationToken cancellationToken = default(CancellationToken))
        {
            var queueDirectory = new DirectoryInfo(Path.Combine(_baseDirectory.FullName, queueName));
            var queue = new FilesystemMessageQueue(queueDirectory, listener, options);
            if (!_queues.TryAdd(queueName, queue))
            {
                throw new QueueAlreadyExistsException(queueName);
            }

            cancellationToken.ThrowIfCancellationRequested();

            Log.DebugFormat("Initializing filesystem queue named \"{0}\" in path \"{1}\"...", queueName, queueDirectory);
            await queue.Init(cancellationToken);
            Log.DebugFormat("Filesystem queue \"{0}\" created successfully", queueName);
        }
        public Task CreateQueue(QueueName queueName, IQueueListener listener, QueueOptions options = default(QueueOptions), CancellationToken cancellationToken = default(CancellationToken))
        {
            CheckDisposed();
            var connection = _connectionManager.GetConnection(_uri);
            var queue = new RabbitMQQueue(queueName, listener, connection, _encoding, options);
            if (!_queues.TryAdd(queueName, queue))
            {
                throw new QueueAlreadyExistsException(queueName);
            }

            Log.DebugFormat("Initializing RabbitMQ queue \"{0}\"", queueName);
            queue.Init();
            Log.DebugFormat("RabbitMQ queue \"{0}\" created successfully", queueName);

            return Task.FromResult(true);
        }
Пример #20
0
 public Engine(INetworkServer server,
               IPolicyServer policyServer,
               TServer thriftServer,
               DbLoader dbLoader,
               IPlayerSelectorFactory playerSelector,
               IPlayersRemoverFactory playersRemoverFactory,
               IStrongholdManager strongholdManager,
               IBarbarianTribeManager barbarianTribeManager,
               IWorld world,
               SystemVariablesUpdater systemVariablesUpdater,
               IScheduler scheduler,
               IDbManager dbManager,
               StrongholdActivationChecker strongholdActivationChecker,
               StrongholdChecker strongholdChecker,
               BarbarianTribeChecker barbarianTribeChecker,
               ICityChannel cityChannel,
               IStrongholdManagerLogger strongholdManagerLogger,
               StoreSync storeSync,
               IQueueListener queueListener,
               MapDataExport mapDataExport)
 {
     this.server                = server;
     this.policyServer          = policyServer;
     this.thriftServer          = thriftServer;
     this.dbLoader              = dbLoader;
     this.playerSelector        = playerSelector;
     this.playersRemoverFactory = playersRemoverFactory;
     this.strongholdManager     = strongholdManager;
     this.barbarianTribeManager = barbarianTribeManager;
     this.world = world;
     this.systemVariablesUpdater = systemVariablesUpdater;
     this.scheduler = scheduler;
     this.dbManager = dbManager;
     this.strongholdActivationChecker = strongholdActivationChecker;
     this.strongholdChecker           = strongholdChecker;
     this.barbarianTribeChecker       = barbarianTribeChecker;
     this.cityChannel             = cityChannel;
     this.strongholdManagerLogger = strongholdManagerLogger;
     this.storeSync     = storeSync;
     this.queueListener = queueListener;
     this.mapDataExport = mapDataExport;
 }
Пример #21
0
        /// <inheritdoc />
        /// <summary>
        /// Initializes a new <see cref="T:Platibus.Filesystem.FilesystemMessageQueue" />
        /// </summary>
        /// <param name="queueName">The name of the queue</param>
        /// <param name="listener">The listener that will consume messages from the queue</param>
        /// <param name="options">(Optional) Queueing options</param>
        /// <param name="diagnosticService">(Optional) The service through which diagnostic events
        ///     are reported and processed</param>
        /// <param name="directory">The directory into which message files will be persisted</param>
        /// <param name="securityTokenService">The service used to issue and validate security
        ///     tokens stored with the persisted messages to preserve the security context in which
        ///     the message was received</param>
        /// <param name="messageEncryptionService"></param>
        public FilesystemMessageQueue(QueueName queueName, IQueueListener listener, QueueOptions options,
                                      IDiagnosticService diagnosticService, DirectoryInfo directory, ISecurityTokenService securityTokenService,
                                      IMessageEncryptionService messageEncryptionService)
            : base(queueName, listener, options, diagnosticService)
        {
            if (queueName == null)
            {
                throw new ArgumentNullException(nameof(queueName));
            }
            if (listener == null)
            {
                throw new ArgumentNullException(nameof(listener));
            }

            _directory                = directory ?? throw new ArgumentNullException(nameof(directory));
            _deadLetterDirectory      = new DirectoryInfo(Path.Combine(directory.FullName, "dead"));
            _securityTokenService     = securityTokenService ?? throw new ArgumentNullException(nameof(securityTokenService));
            _messageEncryptionService = messageEncryptionService;

            MessageEnqueued         += OnMessageEnqueued;
            MessageAcknowledged     += OnMessageAcknowledged;
            MaximumAttemptsExceeded += OnMaximumAttemptsExceeded;
        }
        /// <summary>
        /// Initializes a new <see cref="AbstractMessageQueue"/> with the specified values
        /// </summary>
        /// <param name="queueName">The name of the queue</param>
        /// <param name="listener">The object that will be notified when messages are
        ///     added to the queue</param>
        /// <param name="options">(Optional) Settings that influence how the queue behaves</param>
        /// <param name="diagnosticService">(Optional) The service through which diagnostic events
        /// are reported and processed</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="queueName"/>, or
        /// <paramref name="listener"/> are <c>null</c></exception>
        protected AbstractMessageQueue(QueueName queueName, IQueueListener listener, QueueOptions options = null, IDiagnosticService diagnosticService = null)
        {
            QueueName         = queueName ?? throw new ArgumentNullException(nameof(queueName));
            _listener         = listener ?? throw new ArgumentNullException(nameof(listener));
            DiagnosticService = diagnosticService ?? Diagnostics.DiagnosticService.DefaultInstance;

            var myOptions = options ?? new QueueOptions();

            _autoAcknowledge = myOptions.AutoAcknowledge;
            _maxAttempts     = myOptions.MaxAttempts;
            _retryDelay      = myOptions.RetryDelay;

            var concurrencyLimit = myOptions.ConcurrencyLimit;

            _cancellationTokenSource = new CancellationTokenSource();
            _queuedMessages          = new ActionBlock <QueuedMessage>(
                async msg => await ProcessQueuedMessage(msg, _cancellationTokenSource.Token),
                new ExecutionDataflowBlockOptions
            {
                CancellationToken      = _cancellationTokenSource.Token,
                MaxDegreeOfParallelism = concurrencyLimit
            });
        }
Пример #23
0
        /// <summary>
        /// Initializes a new <see cref="RabbitMQQueue"/>
        /// </summary>
        /// <param name="connection">The connection to the RabbitMQ server</param>
        /// <param name="queueName">The name of the queue</param>
        /// <param name="listener">The listener that will receive new messages off of the queue</param>
        /// <param name="encoding">(Optional) The encoding to use when converting serialized message
        ///     content to byte streams</param>
        /// <param name="options">(Optional) Queueing options</param>
        /// <param name="diagnosticService">(Optional) The service through which diagnostic events
        ///     are reported and processed</param>
        /// <param name="securityTokenService">(Optional) The message security token
        ///     service to use to issue and validate security tokens for persisted messages.</param>
        /// <param name="messageEncryptionService"></param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="queueName"/>,
        /// <paramref name="listener"/>, or <paramref name="connection"/> is <c>null</c></exception>
        public RabbitMQQueue(IConnection connection,
                             QueueName queueName, IQueueListener listener,
                             Encoding encoding, QueueOptions options,
                             IDiagnosticService diagnosticService,
                             ISecurityTokenService securityTokenService,
                             IMessageEncryptionService messageEncryptionService)
        {
            _queueName          = queueName ?? throw new ArgumentNullException(nameof(queueName));
            _queueExchange      = _queueName.GetExchangeName();
            _retryQueueName     = queueName.GetRetryQueueName();
            _retryExchange      = _queueName.GetRetryExchangeName();
            _deadLetterExchange = _queueName.GetDeadLetterExchangeName();

            _listener             = listener ?? throw new ArgumentNullException(nameof(listener));
            _connection           = connection ?? throw new ArgumentNullException(nameof(connection));
            _securityTokenService = securityTokenService ?? throw new ArgumentNullException(nameof(securityTokenService));
            _encoding             = encoding ?? Encoding.UTF8;

            var myOptions = options ?? new QueueOptions();

            _ttl             = myOptions.TTL;
            _autoAcknowledge = myOptions.AutoAcknowledge;
            _maxAttempts     = myOptions.MaxAttempts;
            _retryDelay      = myOptions.RetryDelay;
            _isDurable       = myOptions.IsDurable;

            var concurrencyLimit = myOptions.ConcurrencyLimit;

            _cancellationTokenSource  = new CancellationTokenSource();
            _diagnosticService        = diagnosticService ?? DiagnosticService.DefaultInstance;
            _messageEncryptionService = messageEncryptionService;

            var consumerTag = _queueName;

            _consumer = new DurableConsumer(_connection, queueName, HandleDelivery, consumerTag,
                                            concurrencyLimit, _autoAcknowledge, _diagnosticService);
        }
Пример #24
0
 public ScenarioRunnerService()
 {
     IContainer container = Container();
     _queueListener = container.Resolve<IQueueListener>();
 }
 public BrokerWorkerControllerQueueWatcher(IController instance, IQueueListener <CloudQueueCmdDto> listener, IQueueWriter <CloudQueueResponseDto> writer) : base(listener, writer)
 {
     this.instance = instance;
     this.RegisterCmdDelegates();
 }
Пример #26
0
 public void SetListener(IQueueListener listener)
 {
     this.listener = listener;
 }
Пример #27
0
 /// <summary>
 /// Creates an uninitialized concrete instance of <typeparamref name="TQueue"/>
 /// </summary>
 /// <param name="queueName">The name of the queeue</param>
 /// <param name="listener">The object that will consume messages from the queue</param>
 /// <param name="options">(Optional) Options that govern how the queue behaves</param>
 /// <param name="cancellationToken">(Optional) A cancellation token that can be used
 /// by the caller to cancel queue creation if necessary</param>
 /// <returns>Returns a task whose result is an uninitialized concrete instance of
 /// <typeparamref name="TQueue"/></returns>
 protected abstract Task <TQueue> InternalCreateQueue(QueueName queueName, IQueueListener listener,
                                                      QueueOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
Пример #28
0
 /// <summary>
 /// Call it only if you want a <see cref="IQueueListener{T}"/> to be unregistered.
 /// </summary>
 /// <param name="subscribed">the previously registered instance.</param>
 public void Unsubscribe(IQueueListener <T> subscribed)
 {
     _subscribers.Remove(subscribed);
 }
        /// <inheritdoc />
        protected override Task <SQLMessageQueue> InternalCreateQueue(QueueName queueName, IQueueListener listener,
                                                                      QueueOptions options = null,
                                                                      CancellationToken cancellationToken = new CancellationToken())
        {
            var queue = new SQLMessageQueue(queueName, listener, options, DiagnosticService, ConnectionProvider,
                                            CommandBuilders, _securityTokenService, _messageEncryptionService);

            return(Task.FromResult(queue));
        }
 public void Subscribe(string listenFor, IQueueListener <ControllerMessage> listener)
 {
     listners.Add(listenFor, listener);
 }
 public VirtualQueue(IQueueListener listener, bool autoAcknowledge)
 {
     AutoAcknowledge = autoAcknowledge;
     Listener        = listener;
 }
 public BrokerControllerCloudQueueClient(IQueueListener <CloudQueueResponseDto> listener, IQueueWriter <CloudQueueCmdDto> writer) : base(listener, writer)
 {
     this.RegisterResponseTypes();
 }
        /// <inheritdoc />
        protected override Task <MongoDBMessageQueue> InternalCreateQueue(QueueName queueName, IQueueListener listener,
                                                                          QueueOptions options = null, CancellationToken cancellationToken = new CancellationToken())
        {
            var collectionName = _collectionNameFactory(queueName);
            var queue          = new MongoDBMessageQueue(queueName, listener, options, _diagnosticService, _database, collectionName,
                                                         _securityTokenService, _messageEncryptionService);

            return(Task.FromResult(queue));
        }
Пример #34
0
 protected CloudQueueWatcherBase(IQueueListener <CloudQueueCmdDto> listener, IQueueWriter <CloudQueueResponseDto> writer)
 {
     this.QueueListener = listener;
     this.QueueWriter   = writer;
     this.QueueListener.MessageReceivedCallback = this.InvokeInstanceMethodFromCmdObj;
 }
Пример #35
0
 public MonitorQueueCommand(IQueueListener listener, TextWriter writer)
 {
     _listener = listener;
     _writer   = writer;
 }
 public void Subscribe(string listenFor, IQueueListener<ControllerMessage> listener)
 {
     listners.Add(listenFor, listener);
 }
Пример #37
0
 protected CloudQueueClientBase(IQueueListener <CloudQueueResponseDto> listener, IQueueWriter <CloudQueueCmdDto> writer) : this()
 {
     this.Listener = listener;
     this.Writer   = writer;
     this.Listener.MessageReceivedCallback = this.ReceiveResponse;
 }
Пример #38
0
 /// <inheritdoc />
 protected override Task <InMemoryMessageQueue> InternalCreateQueue(QueueName queueName, IQueueListener listener, QueueOptions options = null,
                                                                    CancellationToken cancellationToken = new CancellationToken())
 {
     return(Task.FromResult(new InMemoryMessageQueue(queueName, listener, options)));
 }
Пример #39
0
 /// <summary>
 /// Call it in order to be able to broadcast any value to <see cref="IQueueListener{T}"/>.
 /// </summary>
 /// <param name="subscriber">The instance you want to register.</param>
 public void Subscribe(IQueueListener <T> subscriber)
 {
     _subscribers.Add(subscriber);
 }
Пример #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageScanRequestListener"/> class.
 /// </summary>
 /// <param name="queueListener">Queue listener implementation.</param>
 /// <param name="scanner">Image Scanner instance.</param>
 public ImageScanRequestListener(IQueueListener queueListener, ImageScanner scanner)
 {
     this.queueListener = queueListener;
     this.scanner       = scanner;
 }
        /// <inheritdoc />
        protected override Task <FilesystemMessageQueue> InternalCreateQueue(QueueName queueName, IQueueListener listener, QueueOptions options = null,
                                                                             CancellationToken cancellationToken = new CancellationToken())
        {
            var queueDirectory = new DirectoryInfo(Path.Combine(_baseDirectory.FullName, queueName));
            var queue          = new FilesystemMessageQueue(queueName, listener, options, _diagnosticService,
                                                            queueDirectory, _securityTokenService, _messageEncryptionService);

            return(Task.FromResult(queue));
        }
Пример #42
0
 /// <summary>
 /// Creates a new <see cref="InMemoryMessageQueue"/>
 /// </summary>
 /// <param name="queueName">The name of the queue</param>
 /// <param name="listener">The object that will be notified when messages are
 ///     added to the queue</param>
 /// <param name="options">(Optional) Settings that influence how the queue behaves</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="queueName"/>, or
 /// <paramref name="listener"/> are <c>null</c></exception>
 public InMemoryMessageQueue(QueueName queueName, IQueueListener listener, QueueOptions options = null)
     : base(queueName, listener, options)
 {
 }