PublishMessages メソッドは AMQP サーバーへメッセージを送信するために使用します。
AMQP サーバーはキュー名をルーティングキーとして使用し、キューを「direct」エクスチェンジに自動的にバインドします。これにより、バインディングを宣言する必要なく特定のキューへメッセージを送信できます(PublishMessage メソッドを呼び出して、Exchange 引数を空、RoutingKey 引数にキュー名を渡すだけです)。
メッセージのパブリッシュ
The method has the following arguments:
- ChannelName: it's the name of the channel (must be open before call this method).
- ExchangeName: it's the name of the exchange, must be no longer of 255 characters and not begin with "amq." (except if passive parameter is true).
- RoutingKey: it's the binding's routing key name.
- Mandatory: if true and the message cannot be routed to any queue, the message is returned by the server, the event OnAMQPBasicReturn is fired.
- Immediate: if true and the message cannot be routed to any queue, the message is returned by the server, the event OnAMQPBasicReturn is fired.
AMQP.PublishMessage('channel_name', 'exchange_name', 'routing_key', 'Hello from sgcWebSockets!!!');
procedure OnAMQPBasicReturn(Sender: TObject; const aChannel: string; const aReturn: TsgcAMQPFramePayload_Method_BasicReturn; const aContent: TsgcAMQPMessageContent);
begin
DoLog('#AMQP_basic_return: ' + aChannel + ' ' + IntToStr(aReturn.ReplyCode) + ' ' + aReturn.ReplyText + ' ' + aContent.Body.AsString);
end;
