How to use the RabbitMQ Web-Stomp Plugin with Delphi and Free Pascal

The RabbitMQ open source message broker includes a web-stomp plugin exposing the STOMP protocol over emulated HTML5 WebSockets. Web-Stomp examples are provided as a plugin which is included in the standard distribution and only needs to be enabled (this requires a broker restart).

For users of the Delphi and Free Pascal client library Habari Client for RabbitMQ, the echo demo, which shows how to use STOMP to do simple message broadcasting, had a small problem: while text sent from the Delphi / Free Pascal side correctly appeared in the browser chat window, text entered in the browser did not reach the Delphi / Free Pascal application.

The reason was a missing STOMP header, content-type. The STOMP specification states that in this case “the receiver SHOULD consider the body to be a binary blob”, and so the chat message will not be treated as a text message.

A change is planned in the RabbitMQ side which will cause the content-type:plain/text message frame to be present. Until its release, Delphi and Free Pascal can use a workaround and convert the binary message content to a string, using UTF8Decode or UTF8ToString.

Hint: the Habari Chat demo application can be used to try the web stomp plugin. Simply use ‘test’ as the chat room name.



Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s