TsgcWSPClient_STOMP_RabbitMQMethods › PublishExchange

PublishExchange Method

Publishes a message directly to an exchange with an optional routing key using the /exchange/name[/routing-key] prefix.

Syntax

procedure PublishExchange(const aName, aRoutingKey, aText: String; const aContentType: String = CS_TEXT_PLAIN; const aTransaction: String = ''; const aHeaders: TStrings = nil);

Parameters

NameTypeDescription
aNameconst StringName of the target exchange (must already exist in RabbitMQ).
aRoutingKeyconst StringOptional routing key appended to the destination. Required for direct and topic exchanges; ignored for fanout. Leave empty to omit the trailing segment.
aTextconst StringMessage body to publish.
aContentTypeconst StringMIME content-type sent as the content-type header. Defaults to text/plain.
aTransactionconst StringOptional transaction identifier. When supplied, the SEND frame is buffered under the named transaction and only delivered on commit.
aHeadersconst TStringsOptional application headers appended to the SEND frame; each item must be formatted as name:value.

Remarks

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.

Example

sgcRabbitMQ.PublishExchange('amq.topic', 'stock.apple.eur', '120.50');

Back to Methods