public bool HandlePeekedMessage(IFileTransport transport, OpenedQueue queue, Message message)
        {
            var doesNotHaveMessageId = (message.Extension.Length < 16);

            if (doesNotHaveMessageId)
            {
                const string errorMessage = "Message does not have Extension set to at least 16 bytes, which will be used as the message id. Probably not a bus message.";
                transport.RaiseMessageSerializationException(queue, message, errorMessage);
                MoveToErrorQueue(queue, message, errorMessage);
                return(true);
            }
            var          id           = message.GetMessageId();
            ErrorCounter errorCounter = null;

            failureCounts.Read(reader => reader.TryGetValue(id, out errorCounter));
            if (errorCounter == null)
            {
                return(false);
            }
            if (errorCounter.FailureCount < numberOfRetries)
            {
                return(false);
            }
            failureCounts.Write(writer =>
            {
                writer.Remove(id);
                MoveToErrorQueue(queue, message, errorCounter.ExceptionText);
            });
            return(true);
        }
        public override bool HandlePeekedMessage(IFileTransport transport1, OpenedQueue queue, Message message)
        {
            Func <CurrentMessageInformation, bool> messageRecieved = information =>
            {
                transport.RaiseAdministrativeMessageArrived(information);
                return(true);
            };

            transport.ReceiveMessageInTransaction(queue, message.Id, messageRecieved, transport.RaiseAdministrativeMessageProcessingCompleted, null, null);
            return(true);
        }
示例#3
0
 public override void Init(IFileTransport transport, OpenedQueue queue)
 {
     parentTransport = transport;
     timeoutMessageIds.Write(writer =>
     {
         foreach (var message in queueStrategy.GetTimeoutMessages(queue))
         {
             writer.Add(message.Time, message.Id);
         }
     });
     timeoutTimer = new Timer(OnTimeoutCallback, null, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1));
 }
示例#4
0
 public override bool HandlePeekedMessage(IFileTransport transport, OpenedQueue queue, Message message)
 {
     using (var tx = new TransactionScope())
     {
         var processMessageAt = DateTime.FromBinary(BitConverter.ToInt64(message.Extension, 16));
         if (CurrentTime >= processMessageAt)
         {
             return(false);
         }
         string id;
         if (!queueStrategy.TryMoveMessage(queue, message, SubQueue.Timeout, out id))
         {
             logger.DebugFormat("Failed to move message to timeout queue");
             return(false);
         }
         tx.Complete();
         logger.DebugFormat("Moving message {0} to timeout queue, will be processed at: {1}", id, processMessageAt);
         timeoutMessageIds.Write(writer => writer.Add(processMessageAt, id));
         return(true);
     }
 }
 public override bool HandlePeekedMessage(IFileTransport transport, OpenedQueue queue, Message message)
 {
     queue.TryGetMessageFromQueue(message.Id);
     return(true);
 }
 public void Init(IFileTransport transport, OpenedQueue queue)
 {
     transport.MessageSerializationException += Transport_OnMessageSerializationException;
     transport.MessageProcessingFailure      += Transport_OnMessageProcessingFailure;
     transport.MessageProcessingCompleted    += Transport_OnMessageProcessingCompleted;
 }
示例#7
0
 public abstract bool HandlePeekedMessage(IFileTransport transport, OpenedQueue queue, Message message);
示例#8
0
 public virtual void Init(IFileTransport transport, OpenedQueue queue)
 {
 }
 public override void Init(IFileTransport parentTransport, OpenedQueue queue)
 {
     transport = parentTransport;
 }