Skip to main content
Version: 2.1

Amazon Simple Queue Service (SQS)

See Amazon Simple Queue Service Developer Guide for general guidance using SQS.

API Access​

The ISQSClient interface and its implementation TSQSClient provides access to all SQS operations.

Enqueuing Messages​

Single messages can be enqueued on an Amazon SQS queue using the SendMessage function. For batches of messages, the SendMessageBatch function is available.

program SendMessage;

{$APPTYPE CONSOLE}

{$R *.res}

uses
AWS.SQS,
System.SysUtils;

var
Client: ISQSClient;
QueueURL: string;
MessageContent: string;

begin
try
MessageContent := '{"Message":"Message..."}';
QueueURL := 'https://...';

Client := TSQSClient.Create;
Client.SendMessage(QueueURL, MessageContent);
except
on E: ESQSException do
Writeln(E.ClassName, ': ', E.Message);
end;
end.

Polling for Messages​

The TSQSQueuePoller class can be used to quickly define a polling operation.

var QueueUrl := 'https://...';
var Poller := TSQSQueuePoller.Create(QueueUrl) as ISQSQueuePoller;
try
Poller.Poll(
procedure(const AMessages: TSQSMessages)
begin
for var LMessage in AMessages do
begin
// If you need more time to process the message,
// change its visibility timeout.
Poller.ChangeMessageVisibilityTimeout(LMessage, 900);
end;
end
);
except on E: ESQSException do
Writeln(E.ClassName, ': ', E.Message);
end;