关于CTS项目的Delphi+ActiveMQ

关于CTS项目的Delphi+ActiveMQ

1、Delphi 2010、Habari_ActiveMQ_Client-2.1。

2、消息发送至cts.queue队列。

program SendMessage;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  BTCommAdapterIndy,
  BTJMSInterfaces,
  BTJMSConnection;

var
  Conn: IConnection;
  Session: ISession;
  Producer: IMessageProducer;
  Destination: IDestination;
  JMSMessage: ITextMessage;

begin
{$IF CompilerVersion>17}
  {$WARN SYMBOL_PLATFORM OFF}
  ReportMemoryLeaksOnShutDown := DebugHook <> 0;
  {$WARN SYMBOL_PLATFORM ON}
{$IFEND}
  try
    Conn := TBTJMSConnection.MakeConnection;
    WriteLn('建立连接');
    Conn.Start;
    Session := Conn.CreateSession(False, amAutoAcknowledge);
    Destination := Session.CreateQueue('cts.queue');
    Producer := Session.CreateProducer(Destination);
    JMSMessage := Session.CreateTextMessage('hi, jzh');
    WriteLn('准备发送');
    Producer.Send(JMSMessage);
    WriteLn('消息发送至 queue ''cts.queue''.');
    Conn.Stop;
    Conn.Close;
    //WriteLn('Press any key');
    ReadLn;
  finally
  end;
end.

3、Habari_ActiveMQ_Client-2.1控件的相关引用:

发表回复

您的电子邮箱地址不会被公开。