The RabbitMQ STOMP plugin supports advanced queue features, which can be defined in the management interface but also from clients when the queue is created. No matter how these features have been declared, RabbitMQ requires that the client specifies the same feature settings anytime when this queue is used.

Example 1: auto-delete

Creation of an auto-delete queue

If the queue does not exist yet, it may be created dynamically by subscribing

ClientCallbackQueue := Session.CreateQueue('Callback?auto-delete=true');

Consumer := Session.CreateConsumer(ClientCallbackQueue);

The admin interface will show that the auto-delete feature is enabled.

Sending a message to the auto-delete queue

Sending a message to this queue requires to specify that the auto-delete feature is enabled:

Msg := Session.CreateTextMessage;

Msg.SetStringProperty('auto-delete', 'true');

Producer.Send(Msg);

Example 2: x-max-priority

Creation of the queue

If the queue does not exist yet, it may be created dynamically by subscribing

PriorityQueue := Session.CreateQueue('Priority?x-max-priority=20');

Consumer := Session.CreateConsumer(PriorityQueue);

The admin interface will show that the maximum priority is 20.

Sending a message to the queue

Sending a message to this queue requires to specify that the maximum priority is 20:

Msg := Session.CreateTextMessage;

Msg.SetIntProperty('x-max-priority', 20);

Producer.Send(Msg);

Hint: check the broker log

If your STOMP client code works with special destination features and does not work as expected, always check the RabbitMQ broker log file. On Windows, you may find it in %APPDATA%\RabbitMQ\log. On Unix, it is located in ${install_prefix}/var/log/rabbitmq (File Locations documentation).

For example, this error message appears if a STOMP client tries to use a exclusive queue from a second connection:

STOMP error frame sent:
Message: resource_locked
Detail: "RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'QueueTest' in vhost '/'\n"

Note

All code examples use the Habari Client for RabbitMQ STOMP library for Delphi and Free Pascal.

habari_logo_2016Habari Client libraries enable Object Pascal applications to take advantage of message broker / message queue technology – which is distributed, loosely coupled, reliable and asynchronous – to build integrated systems, using peer-to-peer and publish-subscribe communication models.


Discover more from Habarisoft Blog

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *