示例#1
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);
     }
 }
示例#2
0
 private void BatchPersistMessages(BatchMessageLogRecord batchRecord)
 {
     foreach (var record in batchRecord.Records)
     {
         _chunkWriter.Write(record);
     }
     batchRecord.OnPersisted();
 }