public void Enqueue(T obj)
 {
     using (_locker.AcquireLock())
     {
         _interalQueue.Enqueue(obj);
     }
 }
        public void OnBeforeConsume <TMessage, TConsumer>(IConsume <TMessage> consumer, TMessage message) where TMessage : class where TConsumer : IConsume <TMessage>
        {
            var requiresLocking = typeof(TConsumer).IsOfGenericType(typeof(IConsumeLocked <>));

            if (!requiresLocking)
            {
                return;
            }

            _lock = locker.AcquireLock(GetCorrelationIdentifier <TMessage, TConsumer>(message));
        }
Beispiel #3
0
 private bool IsStillALeader()
 {
     if (!isALeader || watch.ElapsedMilliseconds > lockPingTimeoutInSeconds * 1000) // try to acuire lock if not a leader or after 30 seconds of became a leader
     {
         isALeader = locker.AcquireLock(lockId, lockKeeperId);
         if (isALeader)
         {
             watch.Restart();
         }
     }
     return(isALeader);
 }