Ejemplo n.º 1
0
 public void PushMessage(PulsarMessage message)
 {
     if (message != null)
     {
         //if we are currently processing messages add this message to the pending list
         if (processing)
         {
             try
             {
                 _pendingMessages.Add(message);
             }
             catch (PulsarMessageException pendingMessageAddException)
             {
                 pendingMessageAddException.Source  = "[MessageQueue:PushMessage]";
                 pendingMessageAddException.Message = "Unable to add message to Pending list.";
                 throw pendingMessageAddException;
             }
         }
         else
         {
             try
             {
                 Queue.Add(message);
             }
             catch (PulsarMessageException systemQueueMessageAddException)
             {
                 systemQueueMessageAddException.Source  = "[MessageQueue:PushMessage]";
                 systemQueueMessageAddException.Message = "Unable to add message to System Queue.";
                 throw systemQueueMessageAddException;
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void DetermineMessageViability(PulsarMessage message)
        {
            if (message != null)
            {
                //first, we are going to look at the iterations (-1 indicates an indefinite message, so exit if we find this)
                if (message.Iterations == -1)
                {
                    return;
                }

                //next we'll look at the iterations again to see if it has a value > 0
                if (message.Iterations > 0)
                {
                    if (!IsViableIterative(message))
                    {
                        return;
                    }
                }

                //check time to live
                if (message.TimeToLive <= DateTime.Now)
                {
                    message.MarkedForDeletion = true;
                }
            }
        }
Ejemplo n.º 3
0
 public void PopMessage(PulsarMessage message)
 {
     try
     {
         Queue.Remove(message);
     }
     catch (PulsarMessageException removeMessageException)
     {
         removeMessageException.Source  = "[MessageQueue:PopMessage]";
         removeMessageException.Message = "Unable to remove message from System Queue.";
         throw removeMessageException;
     }
 }
Ejemplo n.º 4
0
 public void PushMessage(PulsarMessage message)
 {
     if (message != null)
     {
         //if we are currently processing messages add this message to the pending list
         if (processing)
         {
             _pendingMessages.Add(message);
         }
         else
         {
             Queue.Add(message);
         }
     }
 }
Ejemplo n.º 5
0
        private static bool IsViableIterative(PulsarMessage message)
        {
            bool returnValue = true;

            if (message != null)
            {
                //if the decrement has resulted in a zero value then queue this message for deletion in the next pass
                if (--message.Iterations == 0)
                {
                    message.MarkedForDeletion = true;
                    returnValue = false;
                }
                return(returnValue);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
 public void PopMessage(PulsarMessage message)
 {
     Queue.Remove(message);
 }