private MemoryRecordsBuilder recordsBuilder(ByteBuffer buffer, byte maxUsableMagic) {
        if (transactionManager != null && maxUsableMagic < RecordBatch.MAGIC_VALUE_V2) {
            throw new UnsupportedVersionException("Attempting to use idempotence with a broker which does not " +
                "support the required message format (v2). The broker must be version 0.11 or later.");
        }
        return MemoryRecords.builder(buffer, maxUsableMagic, compression, TimestampType.CREATE_TIME, 0L);
    }
Append a new batch to the queue

@param topic The topic
@param partition The partition (cannot be RecordMetadata.UNKNOWN_PARTITION)
@param dq The queue
@param timestamp The timestamp of the record
@param key The key for the record
@param value The value for the record
@param headers the Headers for the record
@param callbacks The callbacks to execute
@param buffer The buffer for the new batch
@param nowMs The current time, in milliseconds
clients/src/main/java/org/apache/kafka/clients/producer/internals/RecordAccumulator.java