Beispiel #1
0
 public void EnqueueMessage(EventCommittingContext message)
 {
     lock (_lockObj)
     {
         var eventDict = _aggregateDictDict.GetOrAdd(message.EventStream.AggregateRootId, x => new ConcurrentDictionary <string, byte>());
         if (eventDict.TryAdd(message.EventStream.Id, 1))
         {
             message.MailBox = this;
             _messageQueue.Enqueue(message);
             _logger.InfoFormat("{0} enqueued new message, mailboxNumber: {1}, message: {2}", GetType().Name, Number, _jsonSerializer.Serialize(message.EventStream));
             LastActiveTime = DateTime.Now;
             TryRun();
         }
         else
         {
             throw new DuplicateEventStreamException(message.EventStream);
         }
     }
 }
 public void EnqueueMessage(EventCommittingContext message)
 {
     lock (_lockObj)
     {
         var eventDict = _aggregateDictDict.GetOrAdd(message.EventStream.AggregateRootId, x => new ConcurrentDictionary <string, byte>());
         if (eventDict.TryAdd(message.EventStream.Id, 1))
         {
             message.MailBox = this;
             _messageQueue.Enqueue(message);
             _logger.DebugFormat("{0} enqueued new message, mailboxNumber: {1}, aggregateRootId: {2}, commandId: {3}, eventVersion: {4}, eventStreamId: {5}, eventIds: {6}",
                                 GetType().Name,
                                 Number,
                                 message.AggregateRoot.UniqueId,
                                 message.ProcessingCommand.Message.Id,
                                 message.EventStream.Version,
                                 message.EventStream.Id,
                                 string.Join("|", message.EventStream.Events.Select(x => x.Id))
                                 );
             LastActiveTime = DateTime.Now;
             TryRun();
         }
     }
 }