Exemple #1
0
        private void HandleReadyForWork(OpenedQueue queue, ReadyToWork work)
        {
            logger.DebugFormat("{0} is ready to work", work.Endpoint);
            var needToAddToQueue = KnownWorkers.Add(work.Endpoint);

            if (needToAddToQueue)
            {
                AddWorkerToQueue(queue, work);
            }

            readyForWork.Enqueue(work.Endpoint);
        }
Exemple #2
0
        protected override void HandleLoadBalancerMessages(object msg)
        {
            var heartbeat = msg as Heartbeat;

            if (heartbeat != null)
            {
                timeout.SetHeartbeat(DateTime.Now);
                logger.Debug("Got heartbeat from primary");
                if (tookOverWork)
                {
                    logger.Info("Primary is now back in action, hurray!");
                    StartTrackingHeartbeats();
                }
            }
            var readyForWorkQueueUriMessage = msg as ReadyForWorkQueueUri;

            if (readyForWorkQueueUriMessage != null)
            {
                logger.InfoFormat("Got ReadyForWork endpoint from primary : {0}", readyForWorkQueueUriMessage.Endpoint);
                readyForWorkQueueUriFromPrimary = readyForWorkQueueUriMessage.Endpoint;
            }
            var newEndpoint = msg as NewEndpointPersisted;

            if (newEndpoint != null)
            {
                logger.InfoFormat("Got new endpoint persisted event from primary: {0}", newEndpoint.PersistedEndpoint);
                KnownEndpoints.Add(newEndpoint.PersistedEndpoint);
            }
            var newWorker = msg as NewWorkerPersisted;

            if (newWorker != null)
            {
                logger.InfoFormat("Got new worker persisted event from primary: {0}", newWorker.Endpoint);
                KnownWorkers.Add(newWorker.Endpoint);
            }
        }