AMQP 0.9.1 Protocol
The widely-deployed AMQP version used by RabbitMQ. Full support for exchanges, queues, bindings, consumer acknowledgments, and transactions.
The widely-deployed AMQP version used by RabbitMQ. Full support for exchanges, queues, bindings, consumer acknowledgments, and transactions.
The de facto standard for RabbitMQ integration, used in thousands of production deployments worldwide.
AMQP 0.9.1 is the protocol version natively supported by RabbitMQ. It defines a rich messaging model based on exchanges, queues, and bindings that enables sophisticated routing patterns. sgcWebSockets provides a complete AMQP 0.9.1 client implementation that connects directly to RabbitMQ on port 5672, supporting channel multiplexing, publisher confirms, consumer acknowledgments, and transactional messaging.
Connect to RabbitMQ, declare a queue, and consume 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 := '/';
AMQPClient.OnAMQPConnect := OnAMQPConnect;
AMQPClient.OnAMQPMessage := OnAMQPMessage;
AMQPClient.Connect;
end;
procedure TForm1.OnAMQPConnect(Sender: TObject);
begin
AMQPClient.OpenChannel(1);
AMQPClient.DeclareQueue(1, 'orders',
False, True, False, False);
AMQPClient.BasicConsume(1, 'orders',
'consumer-1', False, False, False, False);
end;
procedure TForm1.OnAMQPMessage(Sender: TObject;
aChannel: Integer; aMessage: TsgcAMQPMessage);
begin
Memo1.Lines.Add('Received: ' + aMessage.Body);
AMQPClient.BasicAck(aChannel, aMessage.DeliveryTag, False);
end;
Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.