コード例 #1
0
        /// <summary>
        /// Receives the remove message from the bus.
        /// </summary>
        /// <param name="message">The message.</param>
        internal void ReceiveRemoveMessage(CacheWasUpdatedMessage message)
        {
            if (RockMessageBus.IsFromSelf(message))
            {
                // We already took care of Clearing the cache for our instance, so
                // we can ignore this message.
                RockLogger.Log.Debug(RockLogDomains.Bus, $"Cache RemoveMessage was from ourselves( {message.SenderNodeName} ). Skipping. {message.ToDebugString()}.");
                return;
            }

            if (message.Key.IsNullOrWhiteSpace())
            {
                // A Key needs to be specified
                return;
            }

            if (message.Region.IsNotNullOrWhiteSpace())
            {
                CacheManager.Remove(message.Key, message.Region);
            }
            else
            {
                CacheManager.Remove(message.Key);
            }
        }
コード例 #2
0
        /// <inheritdoc />
        public override void Consume(PageRouteWasUpdatedMessage message)
        {
            // Check if Rock is started
            if (!RockMessageBus.IsRockStarted)
            {
                // Don't publish events until Rock is all the way started
                var logMessage = $"'Page Route Was Updated' message was not consumed because Rock is not fully started.";

                var elapsedSinceProcessStarted = RockDateTime.Now - RockInstanceConfig.ApplicationStartedDateTime;

                if (elapsedSinceProcessStarted.TotalSeconds > RockMessageBus.MAX_SECONDS_SINCE_STARTTIME_LOG_ERROR)
                {
                    RockLogger.Log.Error(RockLogDomains.Bus, logMessage);
                    ExceptionLogService.LogException(new BusException(logMessage));
                }
                else
                {
                    RockLogger.Log.Debug(RockLogDomains.Bus, logMessage);
                }

                return;
            }

            // Do not reregister the routes is the message was sent from this node as that has already been done.
            if (RockMessageBus.IsFromSelf(message))
            {
                RockLogger.Log.Debug(RockLogDomains.Bus, $"Skipping 'Page Route Was Updated Message' because this node ({message.SenderNodeName}) was the publisher.");
                return;
            }

            RockLogger.Log.Debug(RockLogDomains.Bus, $"Consumed 'Page Route Was Updated Message' on node {RockMessageBus.NodeName}.");
            RockRouteHandler.RemoveRockPageRoutes();
            RockRouteHandler.RegisterRoutes();
        }
コード例 #3
0
        /// <summary>
        /// Receives the clear message from the message bus.
        /// </summary>
        /// <param name="message">The message.</param>
        internal void ReceiveClearMessage(CacheWasUpdatedMessage message)
        {
            if (RockMessageBus.IsFromSelf(message))
            {
                // We already took care of Clearing the cache for our instance, so
                // we can ignore this message.
                RockLogger.Log.Debug(RockLogDomains.Bus, $"Cache ClearMessage was from ourselves( {message.SenderNodeName} ). Skipping. {message.ToDebugString()}.");
                return;
            }

            CacheManager.Clear();
        }