STOMP Protocol

Simple Text Oriented Messaging Protocol for interoperable messaging. Connect to RabbitMQ, ActiveMQ, and any STOMP-compatible broker from your Delphi applications.

Resposta rápida: o sgcWebSockets adiciona mensageria STOMP ao TsgcWebSocketClient através de sua propriedade STOMP, para que aplicativos Delphi e C++ Builder possam assinar, enviar, executar transações e negociar heart-beats sobre WebSocket com RabbitMQ, ActiveMQ ou qualquer broker STOMP.

What is STOMP?

STOMP provides a simple, text-based messaging protocol that enables interoperability between different message brokers and client implementations.

Simple, Interoperable Messaging

STOMP is designed to be simple and easy to implement. Unlike binary protocols, STOMP uses a text-based frame format that is human-readable and straightforward to debug. It defines a small set of commands — CONNECT, SEND, SUBSCRIBE, UNSUBSCRIBE, ACK, NACK, BEGIN, COMMIT, ABORT, and DISCONNECT — that cover all common messaging patterns. sgcWebSockets implements the STOMP protocol over WebSocket connections, enabling browser and native clients to communicate with enterprise message brokers.

  • Human-readable text-based protocol
  • Works with any STOMP-compatible broker
  • Simple command set for rapid development
  • Runs over WebSocket for browser compatibility
SEND destination:/queue CLIENT BROKER

STOMP Features

Enterprise messaging made simple with a clean, text-based protocol.

Text-Based Protocol

Human-readable frames make debugging and development straightforward. Each frame consists of a command, headers, and an optional body.

RabbitMQ & ActiveMQ

Fully compatible with RabbitMQ and ActiveMQ message brokers, providing access to enterprise messaging infrastructure.

CONNECT/SEND/SUBSCRIBE

Clean command set covering connection management, message sending, and topic subscription with clear semantics.

Receipt Confirmation

Request receipt confirmations from the broker to ensure your messages have been received and processed successfully.

Transaction Support

Group multiple SEND and ACK operations into atomic transactions with BEGIN, COMMIT, and ABORT commands.

Heart-Beat Negotiation

Automatic keep-alive mechanism to detect broken connections and maintain persistent broker sessions.

STOMP Use Cases

Enterprise messaging scenarios where STOMP provides simple, reliable communication.

Enterprise Message Queuing

Connect Delphi applications to enterprise message queues for reliable, asynchronous communication between systems.

Microservices Communication

Enable loosely-coupled communication between microservices using topic-based messaging and queue patterns.

Event-Driven Architectures

Build event-driven systems where components react to events published through STOMP message brokers.

Cross-Platform Messaging

Bridge communication between applications written in different languages and frameworks through a common protocol.

Delphi STOMP Example

Connect to a STOMP broker, subscribe to a destination, and send messages.

uses
  sgcWebSocket_Client, sgcWebSocket_Types;

var
  WSClient: TsgcWebSocketClient;

procedure TForm1.FormCreate(Sender: TObject);
begin
  WSClient := TsgcWebSocketClient.Create(nil);
  WSClient.Host := 'broker.example.com';
  WSClient.Port := 15674;
  WSClient.Specifications.RFC6455.Protocol := 'stomp';

  // Configure STOMP protocol
  WSClient.STOMP.Enabled := True;
  WSClient.STOMP.Authentication.Username := 'guest';
  WSClient.STOMP.Authentication.Password := 'guest';
  WSClient.STOMP.VirtualHost := '/';
  WSClient.STOMP.HeartBeat.Outgoing := 10000;
  WSClient.STOMP.HeartBeat.Incoming := 10000;

  // Set up event handlers
  WSClient.OnSTOMPConnected := OnSTOMPConnected;
  WSClient.OnSTOMPMessage := OnSTOMPMessage;
  WSClient.OnSTOMPReceipt := OnSTOMPReceipt;
end;

procedure TForm1.ButtonConnectClick(Sender: TObject);
begin
  WSClient.Active := True;
end;

procedure TForm1.OnSTOMPConnected(Sender: TObject);
begin
  // Subscribe to a queue
  WSClient.STOMP.Subscribe('/queue/orders');
end;

procedure TForm1.OnSTOMPMessage(Sender: TObject;
  aDestination, aBody: string);
begin
  // Process incoming messages
  Memo1.Lines.Add(aDestination + ': ' + aBody);
end;

procedure TForm1.ButtonSendClick(Sender: TObject);
begin
  // Send a message to a destination
  WSClient.STOMP.Send('/queue/orders',
    '{"orderId": 12345, "status": "new"}');
end;

Perguntas frequentes sobre STOMP

Dúvidas comuns sobre como conectar aplicativos Delphi e C++ Builder a brokers STOMP.

Coloque um TsgcWebSocketClient, defina seu Host e Port, defina Specifications.RFC6455.Protocol como 'stomp' e, em seguida, habilite a propriedade STOMP. Após conectar, você chama STOMP.Subscribe para receber frames e STOMP.Send para publicar em um destino. O componente implementa os comandos STOMP CONNECT, SEND, SUBSCRIBE, ACK, NACK, BEGIN, COMMIT, ABORT e DISCONNECT.
O client funciona com RabbitMQ e ActiveMQ, e com qualquer message broker compatível com STOMP. Como o STOMP é um protocolo de transmissão simples e baseado em texto, o mesmo componente se comunica com qualquer servidor que implemente a especificação STOMP.
Sim. Você pode agrupar operações SEND e ACK em transações atômicas com BEGIN, COMMIT e ABORT, solicitar confirmações de recebimento do broker e configurar a negociação de heart-beat através de STOMP.HeartBeat.Outgoing e STOMP.HeartBeat.Incoming para manter a conexão ativa e detectar sessões interrompidas. O STOMP roda sobre o transporte WebSocket para mensageria compatível com navegadores.
O sgcWebSockets suporta do Delphi 7 até o mais recente lançamento do Delphi e as versões correspondentes do C++ Builder, no Windows, macOS, Linux, iOS e Android. Baixe a versão de avaliação gratuita para avaliar o client STOMP no seu próprio projeto.

Ready to Get Started with STOMP?

Download the free trial and connect to enterprise message brokers in minutes.