(* Collection of code snippets by Arne Vajhøj *)
(* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) *)
program good2;

uses
  StompClient, StompTypes, delphistomp, laz_synapse, mqu;

type
  GoodMQ = class (MQ)
  public
    function get_connection : TStompClient; override;
    procedure test; override;
  end;

function GoodMQ.get_connection : TStompClient;

var
  con : TStompClient;

begin
  con := TStompClient.Create;
  con.Connect('localhost', 61613);
  get_connection := con;
end;

procedure GoodMQ.test;

var
  con : TStompClient;
  fr : IStompFrame;
  i : integer;
  msg : string;

begin
  con := get_connection;
  con.Subscribe('Qin');
  for i := 1 to 10 do begin
    fr := con.Receive;
    msg := fr.GetBody;
    con.Send('Qout', msg);
  end;
  con.Unsubscribe('Qin');
  con.Disconnect;
end;

begin
  GoodMQ.demo(GoodMQ.Create);
end.

