Exemple #1
0
            protected override async Task OnListenerTaskStartAsync(CancellationToken token)
            {
                _token    = token;
                _receiver = MemoryQueueManager.GetQueue(Connection.Route, Connection.Name);
                while (!_token.IsCancellationRequested)
                {
                    var rcvValue = await _receiver.DequeueAsync(_token).ConfigureAwait(false);

                    if (_token.IsCancellationRequested)
                    {
                        break;
                    }
                    _ = Task.Run(() => EnqueueMessageToProcessAsync(ProcessingTaskAsync, rcvValue));
                }
            }
Exemple #2
0
        protected override void OnInit()
        {
            _receiver = null;

            if (Config != null)
            {
                if (Config.ClientQueues != null)
                {
                    _clientQueues = Config.ClientQueues.FirstOf(
                        c => c.EnvironmentName?.SplitAndTrim(",").Contains(Core.EnvironmentName) == true && c.MachineName?.SplitAndTrim(",").Contains(Core.MachineName) == true,
                        c => c.EnvironmentName?.SplitAndTrim(",").Contains(Core.EnvironmentName) == true,
                        c => c.MachineName?.SplitAndTrim(",").Contains(Core.MachineName) == true,
                        c => c.EnvironmentName.IsNullOrWhitespace());
                }
                _senderOptions          = Config.RequestOptions?.ClientSenderOptions;
                _receiverOptions        = Config.ResponseOptions?.ClientReceiverOptions;
                _receiverOptionsTimeout = _receiverOptions?.TimeoutInSec ?? 20;

                if (_receiverOptions?.Parameters?.Contains("Clone") == true)
                {
                    _cloneObject = _receiverOptions.Parameters["Clone"].ParseTo(false);
                }

                if (_clientQueues != null)
                {
                    if (_clientQueues.RecvQueue != null)
                    {
                        _receiver = MemoryQueueManager.GetQueue(_clientQueues.RecvQueue.Route, _clientQueues.RecvQueue.Name);
                    }
                    foreach (var sender in _clientQueues.SendQueues)
                    {
                        MemoryQueueManager.GetQueue(sender.Route, sender.Name);
                    }
                }
            }
            Core.Status.AttachObject(this);
        }
Exemple #3
0
 protected override void OnDispose()
 {
     _receiver = null;
 }