/// <inheritdoc />
        public void Start(string queueName, bool privateQueue, LocaleQueueMode localeQueueMode, bool transactional, Action <object, CancellationToken> messageHandler, Func <object, Exception, bool> errorHandler, Action heartbeatHandler, int heartRateMilliseconds, bool multiThreadedHandler, bool syncMode, CancellationToken cancellationToken)
        {
            _errorHandlerFunc   = errorHandler;
            _errorHandlerAction = null;

            Start(queueName, privateQueue, localeQueueMode, transactional, messageHandler, heartbeatHandler, heartRateMilliseconds, multiThreadedHandler, syncMode, cancellationToken);
        }
예제 #2
0
        /// <inheritdoc />
        public LocaleQueue(ILogger logger, IMessageQueueManager messageQueueManager, IMessageQueueTransactionFactory messageQueueTransactionFactory, string name, bool privateQueue, LocaleQueueMode localeQueueMode, bool transactional, AccessMode accessMode) : base(logger, messageQueueManager, messageQueueTransactionFactory, name, privateQueue, localeQueueMode.In(LocaleQueueMode.Durable, LocaleQueueMode.DurableCreate), transactional, accessMode)
        {
            _localeQueueMode = localeQueueMode;

            switch (_localeQueueMode)
            {
            case LocaleQueueMode.TemporaryMaster:
                Create();
                base.ConnectInternal();
                break;

            case LocaleQueueMode.DurableCreate:
                CreateIfNotExist();
                break;

            case LocaleQueueMode.Durable:
                break;

            case LocaleQueueMode.TemporarySlave:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private void Start(string queueName, bool privateQueue, LocaleQueueMode localeQueueMode, bool transactional, Action <object, CancellationToken> messageHandler, Action heartbeatHandler, int heartRateMilliseconds, bool multiThreadedHandler, bool syncMode, CancellationToken cancellationToken)
        {
            if (_cancellationTokenSource != null)
            {
                throw new ArgumentException("Handler not stopped");
            }

            if (heartRateMilliseconds <= 0 && heartbeatHandler != null)
            {
                throw new ArgumentException("Invalid Heart Rate", nameof(heartRateMilliseconds));
            }

            _queueName = queueName;
            _cancellationTokenSource = new CancellationTokenSource();
            _syncMode                      = syncMode;
            _queue                         = _queueFactory.CreateLocale(_queueName, privateQueue, localeQueueMode, transactional, AccessMode.Receive);
            _messageHandler                = messageHandler ?? throw new ArgumentNullException(nameof(messageHandler));
            _heartbeatHandler              = heartbeatHandler;
            _heartRateMilliseconds         = heartRateMilliseconds;
            _multiThreadedHandler          = multiThreadedHandler;
            _cancellationTokenRegistration = cancellationToken.Register(Stop);

            if (_syncMode)
            {
                Process();
            }
            else
            {
                _processTask = _taskFactory.Create();
                _processTask.Start(Process, _cancellationTokenSource.Token);
            }

            _logger.Information("Queue Handler started {QueueName}", _queueName);
        }
예제 #4
0
        /// <inheritdoc />
        public ILocaleQueue CreateLocale(string name, bool privateQueue, LocaleQueueMode localeQueueMode, bool transactional, AccessMode accessMode)
        {
            if (!_queues.Any(q => q.Name.Contains(name) || name.Contains(q.Name)))
            {
                _queues.Add(new TestQueue(name, _testMessageBroker));
            }

            return(_queues.SingleOrDefault(q => q.Name.Contains(name) || name.Contains(q.Name)));
        }
 private ILocaleQueue CreateLocalQueue(string queue, bool privateQueue = true, LocaleQueueMode localeQueueMode = LocaleQueueMode.TemporaryMaster)
 {
     return(new LocaleQueue(_logger, _messageQueueManager, _messageQueueTransactionFactory, queue, privateQueue, localeQueueMode, true, AccessMode.SendAndReceive));
 }
예제 #6
0
        private IQueue CreateLocaleQueue(string queue = "MyQueue", bool privateQueue = true, LocaleQueueMode localeQueueMode = LocaleQueueMode.TemporaryMaster, AccessMode accessMode = AccessMode.SendAndReceive, bool transactional = true)
        {
            _messageQueueManager.Get(Arg.Any <string>(), queue, Arg.Any <bool>(), Arg.Any <QueueAccessMode>()).Returns(new System.Messaging.MessageQueue());

            return(new LocaleQueue(_logger, _messageQueueManager, _messageQueueTransactionFactory, queue, privateQueue, localeQueueMode, transactional, accessMode));
        }
 /// <inheritdoc />
 public void Start(string queueName, bool privateQueue, LocaleQueueMode localeQueueMode, bool transactional, Action <object, CancellationToken> messageHandler, Func <object, Exception, bool> errorHandler, Action heartbeatHandler, int heartRateMilliseconds, bool multiThreadedHandler, bool syncMode, CancellationToken cancellationToken)
 {
     Start(messageHandler, (message, exception) => { errorHandler(message, exception); }, heartbeatHandler, heartRateMilliseconds, cancellationToken);
 }
 private ILocaleQueue CreateLocalQueue(string name, bool privateQueue, LocaleQueueMode localeQueueMode = LocaleQueueMode.TemporaryMaster, AccessMode accessMode = AccessMode.Receive, bool transactional = true)
 {
     return(new LocaleQueue(NullLogger.Instance, _messageQueueManager, _messageQueueTransactionFactory, name, privateQueue, localeQueueMode, transactional, accessMode));
 }
 /// <inheritdoc />
 public ILocaleQueue CreateLocale(string name, bool privateQueue, LocaleQueueMode localeQueueMode, bool transactional, AccessMode accessMode)
 {
     return(new LocaleQueue(_logger, _messageQueueManager, _messageQueueTransactionFactory, name, privateQueue, localeQueueMode, transactional, accessMode));
 }