Пример #1
0
        private MessageLogRecord ReadMessage(byte[] recordBuffer)
        {
            var record = new MessageLogRecord();

            record.ReadFrom(recordBuffer);
            return(record);
        }
Пример #2
0
 public void BatchStoreMessageAsync(IQueue queue, IEnumerable <Message> messages, Action <BatchMessageLogRecord, object> callback, object parameter, string producerAddress)
 {
     lock (_lockObj)
     {
         var recordList = new List <MessageLogRecord>();
         foreach (var message in messages)
         {
             var record = new MessageLogRecord(
                 queue.Topic,
                 message.Code,
                 message.Body,
                 queue.QueueId,
                 queue.NextOffset,
                 message.CreatedTime,
                 DateTime.Now,
                 message.Tag,
                 producerAddress ?? string.Empty,
                 null,
                 null);
             recordList.Add(record);
             queue.IncrementNextOffset();
         }
         var batchRecord = new BatchMessageLogRecord(recordList, callback, parameter);
         _batchMessageBufferQueue.EnqueueMessage(batchRecord);
     }
 }
Пример #3
0
 public void StoreMessageAsync(IQueue queue, Message message, Action <MessageLogRecord, object> callback, object parameter, string producerAddress)
 {
     lock (_lockObj)
     {
         var record = new MessageLogRecord(
             message.Topic,
             message.Code,
             message.Body,
             queue.QueueId,
             queue.NextOffset,
             message.CreatedTime,
             DateTime.Now,
             message.Tag,
             producerAddress ?? string.Empty,
             callback,
             parameter);
         _bufferQueue.EnqueueMessage(record);
         queue.IncrementNextOffset();
     }
 }
Пример #4
0
 private void PersistMessages(MessageLogRecord record)
 {
     _chunkWriter.Write(record);
     record.OnPersisted();
 }