Cliente AMQP para Delphi e C++ Builder | eSeGeCe

AMQP Protocol

Advanced Message Queuing Protocol for reliable enterprise messaging. Full support for AMQP 0.9.1 and 1.0, compatible with RabbitMQ and Azure Service Bus.

Resposta rápida: o componente TsgcAMQPClient conecta aplicativos Delphi e C++ Builder a brokers AMQP, implementando tanto o AMQP 0.9.1 quanto o AMQP 1.0 com channels, exchanges, queues, acknowledgments e transações com RabbitMQ e Azure Service Bus.

What is AMQP?

AMQP is an open standard for enterprise messaging that provides reliable, interoperable message delivery across different platforms and implementations.

Enterprise-Grade Message Queuing

AMQP defines a wire-level protocol for message-oriented middleware, ensuring true interoperability between different vendor implementations. Its sophisticated routing model based on exchanges, queues, and bindings supports complex messaging patterns including direct routing, topic-based routing, fan-out, and header-based routing. sgcWebSockets implements both AMQP 0.9.1 (the widely-deployed version used by RabbitMQ) and AMQP 1.0 (the OASIS standard used by Azure Service Bus), giving you maximum flexibility.

  • Wire-level protocol guarantees cross-vendor interoperability
  • Flexible routing with exchanges, queues, and bindings
  • Guaranteed message delivery with acknowledgments
  • Both AMQP 0.9.1 and 1.0 supported
PRODUCER EXCH Q1 Q2 CONSUMER

AMQP Features

Industrial-strength messaging features for mission-critical applications.

Reliable Message Delivery

Messages are never lost with publisher confirms and consumer acknowledgments ensuring end-to-end delivery guarantees.

Exchange/Queue/Binding Model

Flexible routing through direct, topic, fanout, and headers exchanges bound to queues with configurable routing keys.

Message Acknowledgment

Consumers explicitly acknowledge processed messages. Unacknowledged messages are automatically requeued for redelivery.

Transactions

Group publish and acknowledge operations into atomic transactions that either all succeed or all roll back.

Flow Control

Built-in flow control prevents fast producers from overwhelming slow consumers, ensuring stable system performance.

Channel Multiplexing

Multiple logical channels over a single TCP connection, reducing connection overhead while maintaining isolation.

RabbitMQ & Azure Service Bus

Tested and verified with RabbitMQ (AMQP 0.9.1) and Azure Service Bus (AMQP 1.0) for production deployments.

AMQP Use Cases

Mission-critical messaging scenarios where reliability and interoperability matter most.

Financial Transaction Processing

Process financial transactions with guaranteed delivery and exactly-once semantics for banking and payment systems.

Order Management

Manage order workflows with reliable message queuing between order entry, fulfillment, shipping, and notification systems.

Enterprise Service Bus

Build an enterprise service bus connecting disparate systems with reliable, asynchronous message delivery.

Distributed Computing

Distribute work across multiple processing nodes with task queues and result collection patterns.

Audit Logging

Capture and route audit events to logging systems with guaranteed delivery, ensuring no audit trail entries are lost.

Delphi AMQP Example

Connect to an AMQP broker, declare queues, and exchange messages.

uses
  sgcAMQP_Client, sgcAMQP_Classes;

var
  AMQPClient: TsgcAMQPClient;

procedure TForm1.FormCreate(Sender: TObject);
begin
  AMQPClient := TsgcAMQPClient.Create(nil);
  AMQPClient.Host := 'rabbitmq.example.com';
  AMQPClient.Port := 5672;
  AMQPClient.Authentication.Username := 'guest';
  AMQPClient.Authentication.Password := 'guest';
  AMQPClient.VirtualHost := '/';

  // Set up event handlers
  AMQPClient.OnAMQPConnect := OnAMQPConnect;
  AMQPClient.OnAMQPMessage := OnAMQPMessage;
  AMQPClient.Connect;
end;

procedure TForm1.OnAMQPConnect(Sender: TObject);
begin
  // Open a channel
  AMQPClient.OpenChannel(1);

  // Declare a queue
  AMQPClient.DeclareQueue(1, 'orders',
    False, True, False, False);

  // Start consuming messages
  AMQPClient.BasicConsume(1, 'orders',
    'consumer-1', False, False, False, False);
end;

procedure TForm1.OnAMQPMessage(Sender: TObject;
  aChannel: Integer; aMessage: TsgcAMQPMessage);
begin
  // Process the message
  Memo1.Lines.Add('Received: ' + aMessage.Body);

  // Acknowledge the message
  AMQPClient.BasicAck(aChannel, aMessage.DeliveryTag, False);
end;

procedure TForm1.ButtonPublishClick(Sender: TObject);
begin
  // Publish a message to the default exchange
  AMQPClient.BasicPublish(1, '', 'orders',
    '{"orderId": 67890, "total": 99.95}');
end;

Casos de uso do AMQP

Dúvidas comuns sobre enfileiramento de mensagens AMQP a partir do Delphi e C++ Builder.

Crie um TsgcAMQPClient, defina seu Host, Port, Authentication e VirtualHost e, em seguida, chame Connect. A partir do evento OnAMQPConnect você abre um channel com OpenChannel, declara uma queue com DeclareQueue e começa a receber com BasicConsume. Envie mensagens com BasicPublish e confirme-as com BasicAck.
O client implementa tanto o AMQP 0.9.1, a versão amplamente implantada usada pelo RabbitMQ, quanto o AMQP 1.0, o padrão OASIS usado pelo Azure Service Bus. Ele é testado e verificado com RabbitMQ e Azure Service Bus para implantações em produção, e o protocolo a nível de transmissão garante interoperabilidade com outros brokers compatíveis.
Sim. Os publisher confirms e os consumer acknowledgments fornecem garantias de entrega de ponta a ponta, mensagens não confirmadas são automaticamente recolocadas na fila e você pode agrupar operações de publicação e confirmação em transações atômicas. O modelo de exchange, queue e binding suporta roteamento direct, topic, fanout e headers, com multiplexação de channels sobre uma única conexão.
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 AMQP no seu próprio projeto.

Ready to Get Started with AMQP?

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