STOMP Protocol

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

Szybka odpowiedź: sgcWebSockets dodaje obsługę komunikatów STOMP do TsgcWebSocketClient przez właściwość STOMP, dzięki czemu aplikacje Delphi i C++ Builder mogą subskrybować, wysyłać, uruchamiać transakcje i negocjować heart-beaty przez WebSocket z RabbitMQ, ActiveMQ lub dowolnym brokerem 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;

STOMP, najczęściej zadawane pytania

Częste pytania o łączenie aplikacji Delphi i C++ Builder z brokerami STOMP.

Upuść komponent TsgcWebSocketClient, ustaw jego Host i Port, ustaw Specifications.RFC6455.Protocol na 'stomp', a następnie włącz właściwość STOMP. Po połączeniu wywołujesz STOMP.Subscribe, aby odbierać ramki, oraz STOMP.Send, aby publikować do miejsca docelowego. Komponent implementuje polecenia STOMP: CONNECT, SEND, SUBSCRIBE, ACK, NACK, BEGIN, COMMIT, ABORT i DISCONNECT.
Klient współpracuje z RabbitMQ i ActiveMQ oraz z dowolnym brokerem komunikatów zgodnym ze STOMP. Ponieważ STOMP jest prostym, tekstowym protokołem przewodowym, ten sam komponent rozmawia z każdym serwerem implementującym specyfikację STOMP.
Tak. Możesz grupować operacje SEND i ACK w atomowe transakcje za pomocą BEGIN, COMMIT i ABORT, żądać potwierdzeń odbioru od brokera oraz konfigurować negocjację heart-beatów przez STOMP.HeartBeat.Outgoing i STOMP.HeartBeat.Incoming, aby utrzymać połączenie i wykrywać zerwane sesje. STOMP działa na transporcie WebSocket, zapewniając komunikację zgodną z przeglądarką.
sgcWebSockets obsługuje Delphi 7 aż po najnowsze wydanie Delphi oraz odpowiadające im wersje C++ Builder, w systemach Windows, macOS, Linux, iOS i Android. Pobierz bezpłatną wersję próbną, aby ocenić klienta STOMP we własnym projekcie.

Ready to Get Started with STOMP?

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