TsgcWSPClient_STOMP_RabbitMQ › Methods › PublishExchange
Publishes a message directly to an exchange with an optional routing key using the /exchange/name[/routing-key] prefix.
procedure PublishExchange(const aName, aRoutingKey, aText: String; const aContentType: String = CS_TEXT_PLAIN; const aTransaction: String = ''; const aHeaders: TStrings = nil);
| Name | Type | Description |
|---|---|---|
aName | const String | Name of the target exchange (must already exist in RabbitMQ). |
aRoutingKey | const String | Optional routing key appended to the destination. Required for direct and topic exchanges; ignored for fanout. Leave empty to omit the trailing segment. |
aText | const String | Message body to publish. |
aContentType | const String | MIME content-type sent as the content-type header. Defaults to text/plain. |
aTransaction | const String | Optional transaction identifier. When supplied, the SEND frame is buffered under the named transaction and only delivered on commit. |
aHeaders | const TStrings | Optional application headers appended to the SEND frame; each item must be formatted as name:value. |
Sends a SEND frame targeting the exchange directly, which gives full control over routing without going through /topic or /queue helpers. The exchange must exist; otherwise RabbitMQ returns an ERROR.
sgcRabbitMQ.PublishExchange('amq.topic', 'stock.apple.eur', '120.50');