Ejemplo n.º 1
0
 public void MovesMessageToOutgoingHistoryAfterMaxAttempts()
 {
     using (var qf = new QueueStorage("test.esent", new QueueManagerConfiguration()))
     {
         qf.Initialize();
         qf.Global(actions =>
         {
             actions.CreateQueueIfDoesNotExists("test");
             actions.Commit();
         });
         var testMessage = new MessagePayload
         {
             Data = new byte[0],
             DeliverBy = null,
             Headers = new NameValueCollection(),
             MaxAttempts = 1
         };
         var messageId = Guid.Empty;
         qf.Global(actions =>
         {
             var transactionId = Guid.NewGuid();
             messageId = actions.RegisterToSend("localhost", "test", null, testMessage, transactionId);
             actions.MarkAsReadyToSend(transactionId);
             actions.Commit();
         });
         qf.Send(actions =>
         {
             string endpoint;
             var msgs = actions.GetMessagesToSendAndMarkThemAsInFlight(int.MaxValue, int.MaxValue, out endpoint);
             actions.MarkOutgoingMessageAsFailedTransmission(msgs.First().Bookmark, false);
             msgs = actions.GetMessagesToSendAndMarkThemAsInFlight(int.MaxValue, int.MaxValue, out endpoint);
             Assert.Empty(msgs);
             actions.Commit();
         });
         qf.Global(actions =>
         {
             var message = actions.GetSentMessages().FirstOrDefault(x => x.Id.MessageIdentifier == messageId);
             Assert.NotNull(message);
             Assert.Equal(OutgoingMessageStatus.Failed, message.OutgoingStatus);
             actions.Commit();
         });
     }
 }
Ejemplo n.º 2
0
 public void MovesMessageToOutgoingFromHistory()
 {
     using (var qf = new QueueStorage("test.esent", new QueueManagerConfiguration()))
     {
         qf.Initialize();
         qf.Global(actions =>
         {
             actions.CreateQueueIfDoesNotExists("test");
             actions.Commit();
         });
         var testMessage = new MessagePayload
         {
             Data = new byte[0],
             Headers = new NameValueCollection(),
         };
         qf.Global(actions =>
         {
             var transactionId = Guid.NewGuid();
             actions.RegisterToSend("localhost", "test", null, testMessage, transactionId);
             actions.MarkAsReadyToSend(transactionId);
             actions.Commit();
         });
         qf.Send(actions =>
         {
             string endpoint;
             var msgs = actions.GetMessagesToSendAndMarkThemAsInFlight(int.MaxValue, int.MaxValue, out endpoint);
             var bookmark = actions.MarkOutgoingMessageAsSuccessfullySent(msgs[0].Bookmark);
             actions.RevertBackToSend(new[] { bookmark });
             msgs = actions.GetMessagesToSendAndMarkThemAsInFlight(int.MaxValue, int.MaxValue, out endpoint);
             Assert.NotEmpty(msgs);
             actions.Commit();
         });
         qf.Global(actions =>
         {
             var messages = actions.GetSentMessages();
             Assert.Empty(messages);
             actions.Commit();
         });
     }
 }
Ejemplo n.º 3
0
 public QueueManager(string endpoint, string path, QueueManagerConfiguration configuration)
 {
     Configuration = configuration;
     _endpoint = endpoint;
     _path = path;
     _queueStorage = new QueueStorage(path, configuration);
     _queueStorage.Initialize();
     _queueStorage.Global(actions =>
     {
         _receivedMsgs.Add(actions.GetAlreadyReceivedMessageIds());
         actions.Commit();
     });
     HandleRecovery();
 }
Ejemplo n.º 4
0
 public MessageAcceptance(QueueManager parent,
     IList<MessageBookmark> bookmarks,
     IEnumerable<Message> messages,
     QueueStorage queueStorage)
 {
     _parent = parent;
     _bookmarks = bookmarks;
     _messages = messages;
     _queueStorage = queueStorage;
     Interlocked.Increment(ref parent._currentlyInCriticalReceiveStatus);
 }
Ejemplo n.º 5
0
 public QueuedMessagesSender(QueueStorage queueStorage, IQueueManager queueManager)
 {
     _queueStorage = queueStorage;
     _queueManager = queueManager;
 }