Exemple #1
0
        /// <summary>
        /// Sends decision to all connected master nodes
        /// </summary>
        public void SendDecisionToNodes(QueueMessage queueMessage, Decision decision)
        {
            HorseMessage     msg   = new HorseMessage(MessageType.Server, null, 10);
            DecisionOverNode model = new DecisionOverNode
            {
                Queue       = Name,
                MessageId   = queueMessage.Message.MessageId,
                Acknowledge = decision.Acknowledge,
                Allow       = decision.Allow,
                PutBack     = decision.PutBack,
                SaveMessage = decision.SaveMessage
            };

            msg.Serialize(model, Server.MessageContentSerializer);
            Server.NodeManager.SendMessageToNodes(msg);
        }
        /// <summary>
        /// Reads decision and applies it
        /// </summary>
        private void DecisionOverNode(HorseMessage message)
        {
            DecisionOverNode model = message.Deserialize <DecisionOverNode>(_server.Server.MessageContentSerializer);

            if (model == null)
            {
                return;
            }

            HorseQueue queue = _server.Server.FindQueue(model.Queue);

            if (queue == null)
            {
                return;
            }

            Decision decision = new Decision(model.Allow, model.SaveMessage, model.PutBack, model.Acknowledge);

            _ = queue.ApplyDecisionOverNode(model.MessageId, decision);
        }