sgcMQ Every broker, one carrier. No DLL to ship.

Seven client components speak MQTT 3.1.1 and 5.0, AMQP 0.9.1, AMQP 1.0, the Apache Kafka wire protocol and STOMP 1.0 through 1.2, with broker dialects for RabbitMQ and ActiveMQ. Every frame is parsed and written in Object Pascal inside the library, so there is no librdkafka, no Paho, no Qpid and no DLL to ship. All seven ride on one TsgcTCPClient, opened plain or wrapped in TLS.

A single package of sgcWebSockets. See pricing →
  • MQTT 3.1.1 & 5.0
  • AMQP 0.9.1
  • AMQP 1.0
  • Apache Kafka
  • STOMP 1.0 to 1.2
  • Delphi 7 to 13
  • C++ Builder
  • 7Client components on one palette page
  • 5Protocol families, each parsed in Object Pascal
  • 6Targets: Win32, Win64, Linux64, macOS, iOS, Android
  • 0External libraries: no librdkafka, Paho, Qpid or DLL
  • 1Transport carrier for all seven components
One API style

One component per protocol. The same shape for all seven.

Drop the protocol component on a form, assign a TsgcTCPClient to its Client property, wire the events, then call the protocol's own verbs. The naming is consistent across all seven, so learning one gets you most of the way through the rest.

One pattern for every broker: a TsgcTCPClient attached to a protocol component through the Client property, over plain TCP or TLS

A TCP client, plus a protocol component

The TsgcTCPClient owns the socket, the host and the port. The protocol component attaches through its Client property and speaks MQTT, AMQP, Kafka or STOMP on top. Switching from a plain listener to an encrypted one is a port number and TLS := True on the carrier, and nothing above it changes.

Connecting to an MQTT broker: the Delphi code next to the CONNECT and CONNACK exchange

Connected in a handful of lines

Point the carrier at your broker, attach TsgcWSPClient_MQTT, choose version 5 or 3.1.1 with one MQTTVersion property and set Active to True. That is the whole connection.

MQTT quality of service 0, 1 and 2 with the PUBLISH, PUBACK, PUBREC, PUBREL and PUBCOMP exchange

The whole QoS machinery, surfaced as events

QoS 0, 1 and 2, with the PUBACK, PUBREC, PUBREL and PUBCOMP exchange surfaced as events rather than hidden. Retained messages, Last Will and Testament, wildcard subscriptions and resumable sessions come with it.

Production settings on the TCP client: WatchDog, HeartBeat and TLS, with authentication on the protocol component

Production settings live on the carrier

WatchDog reconnects after a dropped link, the heartbeat keeps it alive and TLS encrypts it. They sit on the TCP client, so you set them once whatever protocol rides on top. Authentication belongs to the protocol component itself.

Watch it run

Publish and subscribe from Delphi, in a few minutes.

A narrated, captioned quickstart: one pattern for every broker, an MQTT connection, topics and quality of service, then the settings that matter in production. Nothing downloads until you press play.

sgcMQ quickstart

Connect to a broker, subscribe to a topic filter and publish, from Delphi.

  1. One pattern, every brokerCreate a TCP client, which owns the socket, host and port, then attach a protocol component through the Client property.
  2. Connect to an MQTT brokerPoint the TCP client at the broker, attach the MQTT component, choose version 5 or 3.1.1 and set Active to True.
  3. Subscribe and publishSubscribe takes a topic filter and a QoS. Publish takes a topic, the payload, the QoS and a retain flag. Messages arrive on OnMQTTPublish.
  4. The same pattern for the other brokersAMQP 0.9.1 with exchanges, queues and channels, AMQP 1.0, STOMP with the RabbitMQ and ActiveMQ variants, and Kafka with consumer groups and offsets.
  5. Ready for productionWatchDog, heartbeat and TLS on the TCP client, authentication on the protocol component.
Seven components

Five protocol families, natively implemented.

sgcMQ implements the published protocols rather than wrapping a vendor SDK, and every license ships with full source code, so the protocol implementations step through in your own debugger.

MQTT 3.1.1 & 5.0

TsgcWSPClient_MQTT covers both protocol versions behind one MQTTVersion property: QoS 0, 1 and 2, retained messages, Last Will and Testament, wildcard subscriptions and resumable sessions. Version 5 adds reason codes, user properties, topic aliases, shared subscriptions and the AUTH round trip.

View the MQTT client →

AMQP 0.9.1

TsgcWSPClient_AMQP speaks the protocol RabbitMQ was built for: channels, exchange and queue declaration, bindings, consumers, publisher acknowledgements, prefetch QoS and transactions.

View the AMQP 0.9.1 client →

AMQP 1.0

TsgcWSPClient_AMQP1 speaks the OASIS standard behind Azure Service Bus and Event Hubs: containers, sessions, sender and receiver links, credit-based flow control, SASL and the Claims-Based Security helpers. A different wire format and object model, so it has its own component.

View the AMQP 1.0 client →

Apache Kafka

TsgcWSPClient_Kafka talks the Kafka binary protocol over TCP, including the v2 record batch format. Produce with a chosen acks level and gzip compression, consume through a group where coordinator discovery, join, sync, heartbeat and rebalance are handled for you, or read a partition by offset.

View the Kafka client →

STOMP 1.0 to 1.2

TsgcWSPClient_STOMP handles SEND, SUBSCRIBE, UNSUBSCRIBE, ACK, NACK, receipts, bidirectional heart-beating and the BEGIN, COMMIT and ABORT transaction frames. Two descendants turn broker destination conventions into named methods, one for RabbitMQ and one for ActiveMQ.

View the STOMP clients →

Six targets, no asterisk

All seven clients and the carrier under them are registered for Win32, Win64, Linux64, macOS, iOS and Android, from Delphi 7 through RAD Studio 13 and on C++ Builder. The messaging pack carries no platform restriction.

The feature matrix →
The code

Four protocols, the same shape.

Create the protocol component, assign the carrier, hook the events, call the verbs. Switching from a plain listener to an encrypted one is a port number and TLS := True on the carrier, and nothing above it changes.

uses
  sgcTCP_Client_WS, sgcWebSocket_Classes, sgcWebSocket_Protocols;
var
  TCPClient: TsgcTCPClient;
  MQTT: TsgcWSPClient_MQTT;
begin
  TCPClient := TsgcTCPClient.Create(nil);   // plain MQTT over TCP
  TCPClient.Host := 'broker.example.com';
  TCPClient.Port := 1883;
  TCPClient.WatchDog.Enabled := True;

  MQTT := TsgcWSPClient_MQTT.Create(nil);
  MQTT.Client := TCPClient;
  MQTT.MQTTVersion := mqtt5;
  MQTT.Authentication.Enabled  := True;
  MQTT.Authentication.UserName := 'sgc';
  MQTT.Authentication.Password := 'sgc';

  MQTT.LastWillTestament.Enabled := True;
  MQTT.LastWillTestament.Topic   := 'devices/sensor-01/status';
  MQTT.LastWillTestament.Message := 'offline';
  MQTT.LastWillTestament.QoS     := mtqsAtLeastOnce;
  MQTT.LastWillTestament.Retain  := True;

  MQTT.OnMQTTConnect := MQTTConnect;
  MQTT.OnMQTTPublish := MQTTPublish;

  TCPClient.Active := True;
end;

procedure TForm1.MQTTConnect(Connection: TsgcWSConnection;
  const Session: Boolean; const ReasonCode: Integer;
  const ReasonName: string;
  const ConnectProperties: TsgcWSMQTTCONNACKProperties);
begin
  MQTT.Subscribe('sensors/+/temperature', mtqsAtLeastOnce);
end;

procedure TForm1.MQTTPublish(Connection: TsgcWSConnection;
  aTopic, aText: string;
  PublishProperties: TsgcWSMQTTPublishProperties);
begin
  Memo1.Lines.Add(aTopic + ' = ' + aText);
end;

// For an encrypted broker: same code, TLS on the carrier.
// TCPClient.Port := 8883; TCPClient.TLS := True;
uses
  sgcTCP_Client_WS, sgcWebSocket_Protocols, sgcAMQP_Classes;
var
  TCPClient: TsgcTCPClient;
  AMQP: TsgcWSPClient_AMQP;
begin
  TCPClient := TsgcTCPClient.Create(nil);
  TCPClient.Host := 'broker.example.com';
  TCPClient.Port := 5672;                  // 5671 for the amqps listener

  AMQP := TsgcWSPClient_AMQP.Create(nil);
  AMQP.Client := TCPClient;
  AMQP.AMQPOptions.VirtualHost := '/';
  AMQP.HeartBeat.Enabled  := True;
  AMQP.HeartBeat.Interval := 30;

  AMQP.OnAMQPConnect      := AMQPConnect;
  AMQP.OnAMQPBasicDeliver := AMQPBasicDeliver;

  TCPClient.Active := True;
end;

procedure TForm1.AMQPConnect(Sender: TObject);
begin
  AMQP.OpenChannel('ch1');
  AMQP.DeclareExchange('ch1', 'orders', 'direct');
  AMQP.DeclareQueue('ch1', 'orders_in');
  AMQP.BindQueue('ch1', 'orders_in', 'orders', 'create');
  AMQP.Consume('ch1', 'orders_in');

  // Publish to the exchange with a routing key
  AMQP.PublishMessage('ch1', 'orders', 'create', '{"id":42}');
end;
uses
  sgcTCP_Client_WS, sgcWebSocket_Protocols, sgcKafka_Classes;
var
  TCPClient: TsgcTCPClient;
  Kafka: TsgcWSPClient_Kafka;
begin
  Kafka := TsgcWSPClient_Kafka.Create(nil);
  Kafka.KafkaOptions.ClientId := 'my-delphi-app';
  Kafka.KafkaOptions.Producer.Acks        := kafkaAcksLeader;
  Kafka.KafkaOptions.Producer.Compression := kafkaCompressionGzip;
  Kafka.KafkaOptions.Consumer.GroupId     := 'my-group';
  Kafka.KafkaOptions.Consumer.OffsetReset := kafkaOffsetEarliest;
  Kafka.OnKafkaMessage := KafkaMessage;

  TCPClient := TsgcTCPClient.Create(nil);
  Kafka.Client := TCPClient;
  TCPClient.Host := '127.0.0.1';
  TCPClient.Port := 9092;
  TCPClient.Active := True;

  // produce a record to a topic
  Kafka.Produce('my-topic', 'Hello Kafka', 'key-1');

  // consume: subscribe once, then Poll repeatedly (e.g. from a timer)
  Kafka.Subscribe(['my-topic']);
end;

procedure TForm1.KafkaMessage(Sender: TObject;
  const Message: TsgcKafkaMessage);
begin
  Memo1.Lines.Add(Message.GetKeyString + ' = ' + Message.GetValueString);
end;

// fetch records from a timer, commit when a batch is processed
var
  Messages: TsgcKafkaMessages;
begin
  Messages := Kafka.Poll(1000);
  try
    if Messages.Count > 0 then
      Kafka.CommitSync;
  finally
    Messages.Free;
  end;
end;
uses
  sgcTCP_Client_WS, sgcWebSocket_Classes, sgcWebSocket_Protocols,
  sgcWebSocket_Protocol_STOMP_Broker_Client,
  sgcWebSocket_Protocol_STOMP_RabbitMQ_Client;
var
  TCPClient: TsgcTCPClient;
  STOMP: TsgcWSPClient_STOMP_RabbitMQ;
begin
  TCPClient := TsgcTCPClient.Create(nil);
  TCPClient.Host := 'rabbit.example.com';
  TCPClient.Port := 61613;             // 61614 for the plugin's TLS listener

  STOMP := TsgcWSPClient_STOMP_RabbitMQ.Create(nil);
  STOMP.Client := TCPClient;
  STOMP.Authentication.Enabled  := True;
  STOMP.Authentication.UserName := 'guest';
  STOMP.Authentication.Password := 'guest';

  STOMP.OnRabbitMQConnected := RabbitMQConnected;
  STOMP.OnRabbitMQMessage   := RabbitMQMessage;

  TCPClient.Active := True;
end;

procedure TForm1.RabbitMQConnected(Connection: TsgcWSConnection;
  Headers: TsgcWSRabbitMQSTOMPHeadersConnected);
begin
  // /queue/orders
  STOMP.SubscribeQueue('orders');
  STOMP.PublishQueue('orders', '{"orderId":12345}');
end;

procedure TForm1.RabbitMQMessage(Connection: TsgcWSConnection;
  MessageText: string; Headers: TsgcWSRabbitMQSTOMPHeadersMessage;
  Subscription: TsgcWSBrokerSTOMPSubscriptionItem);
begin
  Memo1.Lines.Add(Headers.Destination + ': ' + MessageText);
end;
  1. Create the protocol componentOne component per protocol: MQTT, AMQP 0.9.1, AMQP 1.0, Kafka, STOMP, STOMP for RabbitMQ and STOMP for ActiveMQ.
  2. Assign the carrierSet its Client property to a TsgcTCPClient with the broker's host and port. TLS, proxy and reconnect are configured there, once.
  3. Hook the eventsConnect, message and acknowledgement events arrive on the component, with the protocol's own properties attached.
  4. Call the verbsSubscribe and Publish, DeclareQueue and Consume, Produce and Poll, SubscribeQueue and PublishQueue: the names the protocol already uses.

The same shape in Object Pascal and in C++ Builder, and the same shape for the other three components. The full feature matrix →

Before you buy

Two things worth knowing first.

What sgcMQ needs from you, and how the bytes reach the broker. Both answers are short, and both are on this page rather than in the small print.

Native broker listeners
protocol            component                       TCP     TLS
MQTT 3.1.1 / 5.0    TsgcWSPClient_MQTT             1883    8883
AMQP 0.9.1          TsgcWSPClient_AMQP             5672    5671
AMQP 1.0            TsgcWSPClient_AMQP1            5672    5671
Apache Kafka        TsgcWSPClient_Kafka            9092       *
STOMP               TsgcWSPClient_STOMP           61613       *
STOMP, RabbitMQ     TsgcWSPClient_STOMP_RabbitMQ  61613   61614
STOMP, ActiveMQ     TsgcWSPClient_STOMP_ActiveMQ  61613   61612

* whatever the broker's own encrypted listener is configured as.
  These are the conventional defaults. The carrier's Port takes
  whatever your deployment actually listens on.

sgcMQ is standalone

Everything the components need is bundled inside sgcMQ: the sgcWebSockets Core runtime, the TsgcTCPClient carrier, the TLS layer and the JSON helpers. One installer, full source code in the box.

Plain TCP and TLS, and only that

Every protocol in the pack rides on a raw socket, opened plain or wrapped in TLS, which is how MQTT, AMQP, Kafka and STOMP are normally deployed. Running a protocol over WebSocket instead, for example MQTT over WebSocket or Web-STOMP, needs the WebSocket client, and that ships with sgcWebSockets. Check which transport your broker exposes before you choose.

Delphi and C++ Builder

sgcMQ targets Delphi 7 through RAD Studio 13 and C++ Builder, on all six platforms. There is no .NET build of this pack. If you need messaging from .NET, that lives in sgcWebSockets.

The carrier does the plumbing

TLSOptions.IOHandler picks OpenSSL for cross-platform builds or SChannel on Windows, WatchDog reconnects after a dropped link, and HTTP CONNECT proxy traversal and IPv6 need no extra configuration. Set it once and every protocol above it inherits it.

sgcMQ implements the published protocols rather than wrapping a vendor SDK, so the broker is your choice: RabbitMQ, Apache Kafka, Eclipse Mosquitto, HiveMQ, EMQX, Apache ActiveMQ, Azure Service Bus and Event Hubs, or AWS IoT Core. Swapping broker is a host, a port and a set of credentials.

Part of sgcWebSockets

A single package of sgcWebSockets, licensed on its own.

sgcMQ bundles the sgcWebSockets Core runtime it is built on, so no other eSeGeCe license is needed. Every license includes full source code and royalty-free deployment on all six targets.

Single

1 developer license. Use on one machine at a time.

€249

Team

2 developer licenses. Use on two machines at a time.

€399

Site

Unlimited developers. All company machines.

€649

MQTT, AMQP 0.9.1 and 1.0, Apache Kafka and STOMP client components for Delphi and C++ Builder, with the sgcWebSockets Core runtime bundled in. Need WebSocket transports or .NET as well? Those ship with sgcWebSockets.

View pricing and licenses
Testimonials

What Developers Say

Trusted by Delphi, C++ Builder, Lazarus and .NET developers around the world.

Your sgcWebSockets library is very useful and easy to setup. Keep up the good work!
Simone Moretti Delphi Developer
sgcWebSockets is amazing and your support is the best!
Christian Meyer Founder & CTO
Thanks so much for your help and support, I love your components.
Mark Steinfeld CTO

Talk to your broker from Delphi.

MQTT, AMQP, Kafka and STOMP in one package, natively implemented, with the sgcWebSockets Core runtime bundled in and full source code in the box. Windows, Linux, macOS, iOS and Android from the same code.

More From eSeGeCe

Other Products by eSeGeCe

sgcMQ shares conventions with the other eSeGeCe component libraries for Delphi, C++ Builder and .NET. They ship with full source, and they deploy royalty-free.

sgcWebSockets

WebSocket, HTTP/2, MQTT, AMQP, WebRTC, AI and 30+ API integrations for Delphi, C++ Builder, Lazarus and .NET. This is where the WebSocket carrier lives.

sgcAuth

OAuth2 client, JWT client and WebAuthn support for Delphi and C++ Builder. Standalone, with the sgcWebSockets Core runtime bundled in.

sgcHTTP

HTTP server, HTTP/2 client, gRPC client and Google Cloud Pub/Sub, Calendar and FCM clients for Delphi and C++ Builder. Standalone, with the sgcWebSockets Core runtime bundled in.

sgcREST

REST server, OpenAPI server and OpenAPI client components for Delphi and C++ Builder. Standalone, with the sgcWebSockets Core runtime bundled in.

sgcAI

AI, LLM and MCP components for Delphi and C++ Builder. Seven LLM providers behind one component, plus MCP, embeddings and speech. Standalone, with the sgcWebSockets Core runtime bundled in.

sgcHTML

Server-side HTML and UI components on Bootstrap 5 and htmx. Put a live dashboard in front of the queues sgcMQ consumes.

sgcQUIC

Raw QUIC transport and an HTTP/3 client and server, with WebTransport. An add-on to sgcWebSockets Enterprise.

sgcOpenAPI

OpenAPI 3.x parser, native Pascal SDK generator, OpenAPI server component, and 1,195+ pre-built cloud SDKs.

sgcSign

XAdES, PAdES, CAdES and ASiC for documents, Authenticode, ClickOnce, NuGet and VSIX for code.

sgcPDF

Create, edit, view, sign, redact and validate PDF files in pure Object Pascal, with no DLL to deploy. Licensed on its own.

sgcBiometrics

Windows Hello, fingerprint sensors and the Windows Biometric Framework for Delphi and C++ Builder.

sgcIndy

Updated Indy TCP/IP components with modern TLS, IPv6 and HTTP/2 for Delphi 7 through 13.

Latest from the blog

View all posts →

You are seeing the sgcMQ view of eSeGeCe.

Show me another angle →
30-Day Money-Back GuaranteeNot satisfied? Request a full refund within 30 days of purchase. See refund policy