You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: many_levels_error_spec.rb
    path of file: ./repos/karafka/spec/integrations/pro/consumption/transactions
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

# Nested transactions should not be allowed.

setup_karafka do |config|
  config.kafka[:'transactional.id'] = SecureRandom.uuid
end

class Consumer < Karafka::BaseC
    
  def consume
    return if DT.key?(:done)

    begin
      transaction do
        transaction do
          transaction do
            producer.produce_async(topic: DT.topic, payload: rand.to_s)
            mark_as_consumed(messages.first, messages.first.offset.to_s)

            raise StandardError
          end
        end
      end
    rescue Karafka::Errors::TransactionAlreadyInitializedError
      DT[:metadata] << offset_metadata
      DT[:done] = true
    end