How to Receive a Message from an Apache ActiveMQ Topic with Open Dylan

W/o Durability

activemq-sample.dylan

module: activemq-sample

define function main (name :: <string>, arguments :: <vector>)
  start-sockets();

  let sock = make(<TCP-socket>, host: "localhost", port: 61613);

  write(sock, "CONNECT\n\n\0");

  force-output(sock;

  let line = read-line(sock);

  ; Skip the CONNECTED frame
  until (string-equal?(line, "\0"))
    line := read-line(sock);
  end until;

  write(sock, "SUBSCRIBE\ndestination:/topic/SampleTopic\n\nack:auto\n\n\0");

  force-output(sock);

  line := read-line(sock);

  ; Seek to the body of the MESSAGE frame
  until (string-equal?(line, ""))
    line := read-line(sock);
  end until;

  format-out("%s\n", read-line(sock));

  write(sock, "DISCONNECT\n\n\0");

  close(sock);
end function;

main(application-name(), application-arguments());

activemq-sample.lid

library: activemq-sample
files: library
       activemq-sample

library.dylan

module: dylan-user

define library activemq-sample
  use common-dylan;

  use io;
  
  use network;

  use strings;
  
  export activemq-sample;
end library;

define module activemq-sample
  use common-dylan;

  use format-out;

  use streams;

  use sockets;

  use strings;
end module;

W/ Durability

activemq-sample.dylan

module: activemq-sample

define function main (name :: <string>, arguments :: <vector>)
  start-sockets();

  let sock = make(<TCP-socket>, host: "localhost", port: 61613);

  write(sock, "CONNECT\nclient-id:SampleClient\n\n\0");

  force-output(sock;

  let line = read-line(sock);

  ; Skip the CONNECTED frame
  until (string-equal?(line, "\0"))
    line := read-line(sock);
  end until;

  write(sock, "SUBSCRIBE\ndestination:/topic/SampleTopic\n\nack:auto\nactivemq.subscriptionName:SampleSubscription\n\n\0");

  force-output(sock);

  line := read-line(sock);

  ; Seek to the body of the MESSAGE frame
  until (string-equal?(line, ""))
    line := read-line(sock);
  end until;

  format-out("%s\n", read-line(sock));

  write(sock, "DISCONNECT\n\n\0");

  close(sock);
end function;

main(application-name(), application-arguments());

activemq-sample.lid

library: activemq-sample
files: library
       activemq-sample

library.dylan

module: dylan-user

define library activemq-sample
  use common-dylan;

  use io;
  
  use network;

  use strings;
  
  export activemq-sample;
end library;

define module activemq-sample
  use common-dylan;

  use format-out;

  use streams;

  use sockets;

  use strings;
end module;

How to Receive a Message from an Apache ActiveMQ Queue with Open Dylan

activemq-sample.dylan

module: activemq-sample

define function main (name :: <string>, arguments :: <vector>)
  start-sockets();

  let sock = make(<TCP-socket>, host: "localhost", port: 61613);

  write(sock, "CONNECT\n\n\0");

  force-output(sock;

  let line = read-line(sock);

  ; Skip the CONNECTED frame
  until (string-equal?(line, "\0"))
    line := read-line(sock);
  end until;

  write(sock, "SUBSCRIBE\ndestination:SampleQueue\n\nack:auto\n\n\0");

  force-output(sock);

  line := read-line(sock);

  ; Seek to the body of the MESSAGE frame
  until (string-equal?(line, ""))
    line := read-line(sock);
  end until;

  format-out("%s\n", read-line(sock));

  write(sock, "DISCONNECT\n\n\0");

  close(sock);
end function;

main(application-name(), application-arguments());

activemq-sample.lid

library: activemq-sample
files: library
       activemq-sample

library.dylan

module: dylan-user

define library activemq-sample
  use common-dylan;

  use io;
  
  use network;

  use strings;
  
  export activemq-sample;
end library;

define module activemq-sample
  use common-dylan;

  use format-out;

  use streams;

  use sockets;

  use strings;
end module;

How to Send a Message to an Apache ActiveMQ Topic with Open Dylan

activemq-sample.dylan

module: activemq-sample

define function main (name :: <string>, arguments :: <vector>)
  start-sockets();

  let sock = make(<TCP-socket>, host: "localhost", port: 61613);

  write(sock, "CONNECT\n\n\0");

  write(sock, "SEND\ndestination:/topic/SampleTopic\n\nSimples Assim\0");

  write(sock, "DISCONNECT\n\n\0");

  close(sock);
end function;

main(application-name(), application-arguments());

activemq-sample.lid

library: activemq-sample
files: library
       activemq-sample

library.dylan

module: dylan-user

define library activemq-sample
  use common-dylan;

  use io;

  use network;

  export activemq-sample;
end library;

define module activemq-sample
  use common-dylan;

  use streams;

  use sockets;
end module;

How to Send a Message to an Apache ActiveMQ Queue with Open Dylan

activemq-sample.dylan

module: activemq-sample

define function main (name :: <string>, arguments :: <vector>)
  start-sockets();

  let sock = make(<TCP-socket>, host: "localhost", port: 61613);

  write(sock, "CONNECT\n\n\0");

  write(sock, "SEND\ndestination:SampleQueue\n\nSimples Assim\0");

  write(sock, "DISCONNECT\n\n\0");

  close(sock);
end function;

main(application-name(), application-arguments());

activemq-sample.lid

library: activemq-sample
files: library
       activemq-sample

library.dylan

module: dylan-user

define library activemq-sample
  use common-dylan;

  use io;

  use network;

  export activemq-sample;
end library;

define module activemq-sample
  use common-dylan;

  use streams;

  use sockets;
end module;

How to Receive a Message from an Apache ActiveMQ Topic with JavaScript

W/o Durability

var conn = new WebSocket('ws://localhost:61614', 'stomp');

conn.onopen = function () {
  conn.send('CONNECT\n\n\0');

  conn.send('SUBSCRIBE\ndestination:/topic/SampleTopic\n\nack:auto\n\n\0');

  conn.send('DISCONNECT\n\n\0');
};

conn.onmessage = function (e) {

  if (e.data.startsWith('MESSAGE'))
    console.log(e.data);

};

W/ Durability

var conn = new WebSocket('ws://localhost:61614', 'stomp');

conn.onopen = function () {
  conn.send('CONNECT\nclient-id:SampleClient\n\n\0');

  conn.send('SUBSCRIBE\ndestination:/topic/SampleTopic\n\nack:auto\nactivemq.subscriptionName:SampleSubscription\n\n\0');

  conn.send('DISCONNECT\n\n\0');
};

conn.onmessage = function (e) {

  if (e.data.startsWith('MESSAGE'))
    console.log(e.data);

};

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

W/o Durability

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:/topic/SampleTopic%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

W/ Durability

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%Nclient-id:SampleClient%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:/topic/SampleTopic%N%Nack:auto%Nactivemq.subscriptionName:SampleSubscription%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

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