コード例 #1
0
 public bool RemoveOperation(OperationItem operation)
 {
     if (!_activeOperations.Remove(operation.CorrelationId))
     {
         LogDebug("RemoveOperation FAILED for {0}", operation);
         return(false);
     }
     LogDebug("RemoveOperation SUCCEEDED for {0}", operation);
     _totalOperationCount = _activeOperations.Count + _waitingOperations.Count;
     return(true);
 }
コード例 #2
0
        public void ScheduleOperationRetry(OperationItem operation)
        {
            if (!RemoveOperation(operation))
            {
                return;
            }

            LogDebug("ScheduleOperationRetry for {0}", operation);
            if (operation.MaxRetries >= 0 && operation.RetryCount >= operation.MaxRetries)
            {
                operation.Operation.Fail(new RetriesLimitReachedException(operation.ToString(), operation.RetryCount));
                return;
            }
            _retryPendingOperations.Add(operation);
        }
コード例 #3
0
        public void ScheduleOperation(OperationItem operation, TcpPackageConnection connection)
        {
            Ensure.NotNull(connection, "connection");

            if (_activeOperations.Count >= _settings.MaxConcurrentItems)
            {
                LogDebug("ScheduleOperation WAITING for {0}.", operation);
                _waitingOperations.Enqueue(operation);
            }
            else
            {
                operation.ConnectionId = connection.ConnectionId;
                operation.LastUpdated  = DateTime.UtcNow;
                _activeOperations.Add(operation.CorrelationId, operation);

                var package = operation.Operation.CreateNetworkPackage(operation.CorrelationId);
                LogDebug("ScheduleOperation package {0}, {1}, {2}.", package.Command, package.CorrelationId, operation);
                connection.EnqueueSend(package);
            }
            _totalOperationCount = _activeOperations.Count + _waitingOperations.Count;
        }
コード例 #4
0
 public bool TryGetActiveOperation(Guid correlationId, out OperationItem operation)
 {
     return(_activeOperations.TryGetValue(correlationId, out operation));
 }
コード例 #5
0
 public void EnqueueOperation(OperationItem operation)
 {
     LogDebug("EnqueueOperation WAITING for {0}.", operation);
     _waitingOperations.Enqueue(operation);
 }