# File examples/putget11_rh1.rb, line 31
  def run
    conn = get_connection() # Use helper method to obtain a Stomp#connection
    raise "Unexpected protocol level" if conn.protocol != Stomp::SPL_11
    #
    # The gem supports repeated headers by allowing the 'value' part of a header
    # to be an Array instance.
    #
    # On 'publish', all values in the Array are placed on the wire and sent to the
    # broker in order.
    #
    # On 'receive', if repeated headers are detected, an Array instance is created
    # to hold the repeated values.  This is presented the the calling client to
    # be processed per client requirements.
    #
    qname = "/queue/nodea.nodeb.nodec"
    data = "message payload: #{Time.now.to_f}"
    key2_repeats = ["key2val3", "key2val2", "key2val1" ]
    headers = {"key1" => "value1",  # A normal header
      "key2" => key2_repeats,       # A repeated header
      "key3" => "value3",           # Another normal header
    }
    #
    # Ship it.
    #
    conn.publish qname, data , headers
    puts "Sent data: #{data}"
    #
    # Receive phase.
    #
    uuid = conn.uuid()
    conn.subscribe qname, {"id" => uuid}
    received = conn.receive
    conn.unsubscribe qname, {"id" => uuid}
    #
    # Check that we received what we sent.
    #
    raise "Unexpected payload" unless data == received.body
    raise "Missing key" unless received.headers["key2"]
    raise "Repeats not present" unless received.headers.has_value?(key2_repeats)
    raise "Unexpected repeat values" unless key2_repeats == received.headers["key2"]
    #
    # Demonstrate how to process repeated headers received by display of those
    # received headers for a visual check.
    #
    received.headers.each_pair do |k,v|
      if v.is_a?(Array)
        v.each do |e|
          puts "#{k}:#{e}"
        end
      else
        puts "#{k}:#{v}"
      end
    end
    #
    # And finally, disconnect.
    #
    conn.disconnect
  end