TsgcWSPClient_STOMP_RabbitMQ › Methods › SubscribeTopic
Subscribes to a RabbitMQ topic using the /topic/name destination prefix.
procedure SubscribeTopic(const aTopic: String; const aDurable: Boolean = True; const aAutoDelete: Boolean = False; const aExclusive: Boolean = False; const aACK: TsgcSTOMPACK = ackAuto; const aOptions: TsgcWSRabbitMQSTOMP_Queue_Options = nil);
| Name | Type | Description |
|---|---|---|
aTopic | const String | Topic name (without the /topic/ prefix). The component builds the final destination as /topic/aTopic and the broker binds it to the amq.topic exchange using the topic as routing key. |
aDurable | const Boolean | If True (default), declares a durable subscription queue that survives a broker restart. |
aAutoDelete | const Boolean | If True, the subscription queue is deleted automatically when the last consumer disconnects. |
aExclusive | const Boolean | If True, the subscription queue is restricted to the current connection and deleted on disconnect. |
aACK | const TsgcSTOMPACK | Acknowledgement mode: ackAuto, ackClient or ackClient-Individual. When not ackAuto the application must call ACK or NACK for every received message. |
aOptions | const TsgcWSRabbitMQSTOMP_Queue_Options | Optional RabbitMQ x-arguments (MessageTTL, Expires, MaxLength, MaxLengthBytes, DeadLetterExchange, DeadLetterRoutingKey, MaxPriority). When nil the component Queue property is used. |
The RabbitMQ STOMP plugin auto-declares an anonymous queue bound to the amq.topic exchange with the topic name as routing key. Incoming messages are delivered through the OnRabbitMQMessage event.
sgcRabbitMQ.SubscribeTopic('prices');