TsgcWSPClient_AMQP › Methods › PublishMessage
Publishes a message to an exchange (basic.publish). Overloaded for string or stream bodies.
procedure PublishMessage(const aChannel, aExchange, aRoutingKey, aMessage: string; aMandatory: Boolean = false; aImmediate: Boolean = false);
| Name | Type | Description |
|---|---|---|
aChannel | const string | Name of the open AMQP channel on which the operation is issued. |
aExchange | const string | Name of the exchange. |
aRoutingKey | const string | Routing key used to match messages published to the exchange. |
aMessage | const string | Message body. |
aMandatory | Boolean | When True the broker returns unroutable messages via basic.return instead of silently dropping them. |
aImmediate | Boolean | When True the broker returns a message that cannot be immediately delivered to a consumer. |
String-body overload. Sends aMessage as the payload, using default basic-properties (content-type and delivery-mode are unset).
sgcWSPClient_AMQP1.PublishMessage('ch1', 'ex.orders', 'orders.new', '{"id":1}');
procedure PublishMessage(const aChannel, aExchange, aRoutingKey: string; aMessage: TStream; aMandatory: Boolean = false; aImmediate: Boolean = false);
| Name | Type | Description |
|---|---|---|
aChannel | const string | Name of the open AMQP channel on which the operation is issued. |
aExchange | const string | Name of the exchange. |
aRoutingKey | const string | Routing key used to match messages published to the exchange. |
aMessage | TStream | Message body. |
aMandatory | Boolean | When True the broker returns unroutable messages via basic.return instead of silently dropping them. |
aImmediate | Boolean | When True the broker returns a message that cannot be immediately delivered to a consumer. |
Stream-body overload. Sends the entire content of aMessage as the payload; useful for binary or large bodies read from a file or memory stream.
vStream := TFileStream.Create('payload.bin', fmOpenRead);
try
sgcWSPClient_AMQP1.PublishMessage('ch1', 'ex.orders', 'orders.new', vStream);
finally
vStream.Free;
end;