How to Receive a Message from an Apache ActiveMQ Queue with GNU Eiffel

class 
  ACTIVEMQ_SAMPLE

create
  make

feature

  make
    local
      access: TCP_ACCESS

      host: HOST

      stream: SOCKET_INPUT_OUTPUT_STREAM
 
    do
      create host.make ("localhost")

      create access.make (host, 61613, True)

      stream := access.stream

      stream.put_string ("CONNECT%N%N%U")

      stream.flush

      -- Skip the CONNECTED frame
      from
        stream.read_line
      until
        stream.last_string.is_equal ("%U")
      loop
        stream.read_line
      end

      stream.put_string ("SUBSCRIBE%Ndestination:SampleQueue%N%Nack:auto%N%N%U")

      stream.flush

      -- Seek to the body of the MESSAGE frame
      from
        stream.read_line
      until
        stream.last_string.is_empty
      loop
        stream.read_line
      end

      stream.read_line

      io.put_line (stream.last_string)

      stream.put_string ("DISCONNECT%N%N%U")

      stream.disconnect
    end

end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s