STOMP with ActiveMQ
Connect your Delphi applications to Apache ActiveMQ using STOMP over WebSocket. Access queues, topics, and durable subscriptions from native code.
Connect your Delphi applications to Apache ActiveMQ using STOMP over WebSocket. Access queues, topics, and durable subscriptions from native code.
Apache ActiveMQ natively supports STOMP over WebSocket, enabling browser and native clients to participate in enterprise messaging.
Apache ActiveMQ is a popular open-source message broker that supports STOMP natively. Its WebSocket transport connector exposes STOMP on port 61614, allowing Delphi applications to connect without additional plugins. sgcWebSockets provides full STOMP protocol support including durable subscriptions, message selectors, priority handling, and transaction management — all features that ActiveMQ exposes through the STOMP protocol.
Connect to ActiveMQ via STOMP and subscribe to a topic.
uses
sgcWebSocket_Client, sgcWebSocket_Types;
var
WSClient: TsgcWebSocketClient;
procedure TForm1.FormCreate(Sender: TObject);
begin
WSClient := TsgcWebSocketClient.Create(nil);
WSClient.Host := 'activemq.example.com';
WSClient.Port := 61614;
WSClient.Specifications.RFC6455.Protocol := 'stomp';
// ActiveMQ STOMP authentication
WSClient.STOMP.Enabled := True;
WSClient.STOMP.Authentication.Username := 'admin';
WSClient.STOMP.Authentication.Password := 'admin';
WSClient.STOMP.HeartBeat.Outgoing := 10000;
WSClient.OnSTOMPConnected := OnSTOMPConnected;
WSClient.OnSTOMPMessage := OnSTOMPMessage;
end;
procedure TForm1.OnSTOMPConnected(Sender: TObject);
begin
// Subscribe to an ActiveMQ topic
WSClient.STOMP.Subscribe('/topic/notifications');
end;
procedure TForm1.OnSTOMPMessage(Sender: TObject;
aDestination, aBody: string);
begin
Memo1.Lines.Add(aDestination + ': ' + aBody);
end;
Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.