STOMP with RabbitMQ
Connect your Delphi applications to RabbitMQ using STOMP over WebSocket. Publish messages, subscribe to queues, and integrate with enterprise messaging infrastructure.
Connect your Delphi applications to RabbitMQ using STOMP over WebSocket. Publish messages, subscribe to queues, and integrate with enterprise messaging infrastructure.
RabbitMQ ships with a built-in STOMP plugin that enables WebSocket-based messaging from any STOMP client.
RabbitMQ is one of the most widely deployed message brokers in the world. Its STOMP plugin (rabbitmq_web_stomp) exposes RabbitMQ queues and exchanges over WebSocket connections, allowing Delphi applications to publish and consume messages without a native AMQP client. sgcWebSockets connects to RabbitMQ’s STOMP endpoint on port 15674, authenticates with the broker, and provides full access to queues, topics, and exchanges.
Connect to RabbitMQ via STOMP, subscribe to a queue, and publish messages.
uses
sgcWebSocket_Client, sgcWebSocket_Types;
var
WSClient: TsgcWebSocketClient;
procedure TForm1.FormCreate(Sender: TObject);
begin
WSClient := TsgcWebSocketClient.Create(nil);
WSClient.Host := 'rabbitmq.example.com';
WSClient.Port := 15674;
WSClient.Specifications.RFC6455.Protocol := 'stomp';
// RabbitMQ STOMP authentication
WSClient.STOMP.Enabled := True;
WSClient.STOMP.Authentication.Username := 'guest';
WSClient.STOMP.Authentication.Password := 'guest';
WSClient.STOMP.VirtualHost := '/';
WSClient.STOMP.HeartBeat.Outgoing := 10000;
WSClient.OnSTOMPConnected := OnSTOMPConnected;
WSClient.OnSTOMPMessage := OnSTOMPMessage;
end;
procedure TForm1.OnSTOMPConnected(Sender: TObject);
begin
// Subscribe to a RabbitMQ queue
WSClient.STOMP.Subscribe('/queue/orders');
end;
procedure TForm1.OnSTOMPMessage(Sender: TObject;
aDestination, aBody: string);
begin
Memo1.Lines.Add(aDestination + ': ' + aBody);
end;
procedure TForm1.ButtonSendClick(Sender: TObject);
begin
WSClient.STOMP.Send('/queue/orders',
'{"orderId": 1234, "status": "new"}');
end;
Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.