Пример #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 MessageLogRecord StoreMessage(int queueId, long queueOffset, Message message)
        {
            var record = new MessageLogRecord(
                message.Topic,
                message.Code,
                message.Body,
                queueId,
                queueOffset,
                message.CreatedTime,
                DateTime.Now);

            _chunkWriter.Write(record);
            return(record);
        }
Пример #4
0
 public void StoreMessageAsync(IQueue queue, Message message, Action <MessageLogRecord, object> callback, object parameter)
 {
     lock (_lockObj)
     {
         var record = new MessageLogRecord(
             message.Topic,
             message.Code,
             message.Body,
             queue.QueueId,
             queue.NextOffset,
             message.CreatedTime,
             DateTime.Now,
             message.Tag,
             callback,
             parameter);
         _bufferQueue.EnqueueMessage(record);
         queue.IncrementNextOffset();
     }
 }
Пример #5
0
 private void PersistMessages(MessageLogRecord record)
 {
     _chunkWriter.Write(record);
     record.OnPersisted();
 }
Пример #6
0
 private void PersistMessages(MessageLogRecord message)
 {
     _chunkWriter.Write(message);
     message.OnPersisted();
 }