Message Queue
Queues — drive SQS / Service Bus / Pub/Sub with the real SDK
Message Queue
Emulates message queues: SQS (AWS), Service Bus (Azure), Pub/Sub (GCP).
| Provider | Service | SDK-compat | Driver |
|---|---|---|---|
| AWS | SQS (AwsJson1_0) | ✓ Live | aws.SQS |
| Azure | Service Bus (ARM control plane + REST data plane) | ✓ Live | azure.ServiceBus |
| GCP | Pub/Sub (REST) | ✓ Live | gcp.PubSub |
Use the real SDK (recommended)
import (
"github.com/aws/aws-sdk-go-v2/service/sqs"
awsserver "github.com/stackshy/cloudemu/server/aws"
)
cloud := cloudemu.NewAWS()
ts := httptest.NewServer(awsserver.New(awsserver.Drivers{SQS: cloud.SQS}))
client := sqs.NewFromConfig(cfg, func(o *sqs.Options) {
o.BaseEndpoint = aws.String(ts.URL)
})
q, _ := client.CreateQueue(ctx, &sqs.CreateQueueInput{
QueueName: aws.String("orders"),
})
client.SendMessage(ctx, &sqs.SendMessageInput{
QueueUrl: q.QueueUrl, MessageBody: aws.String("order-123"),
})
rcv, _ := client.ReceiveMessage(ctx, &sqs.ReceiveMessageInput{
QueueUrl: q.QueueUrl, MaxNumberOfMessages: 1,
})
client.DeleteMessage(ctx, &sqs.DeleteMessageInput{
QueueUrl: q.QueueUrl, ReceiptHandle: rcv.Messages[0].ReceiptHandle,
})Same pattern with armservicebus (Azure ARM control plane) + raw HTTP for Service Bus data plane (the modern azservicebus SDK is AMQP-only and out of scope), and google.golang.org/api/pubsub/v1 for GCP Pub/Sub. See SDK-Compat Server.
Operations supported via SDK-compat
SQS: CreateQueue, GetQueueUrl, ListQueues, DeleteQueue, SendMessage, ReceiveMessage, DeleteMessage.
Service Bus: ARM Microsoft.ServiceBus/namespaces[/queues] CRUD + raw-HTTP REST data plane (POST /{ns}/{queue}/messages, DELETE /messages/head).
Pub/Sub: Topics + Subscriptions lifecycle, :publish, :pull, :acknowledge.
Realistic behaviors
- FIFO deduplication: FIFO queues enforce 5-minute deduplication windows using
MessageDeduplicationId. - Visibility timeout: received messages are invisible to other consumers until the timeout expires or the message is deleted.
- Dead-letter queues: messages exceeding
MaxReceiveCountmove to the configured DLQ automatically.
Alternative: Portable Go API
import mqdriver "github.com/stackshy/cloudemu/messagequeue/driver"
q, _ := aws.SQS.CreateQueue(ctx, mqdriver.QueueConfig{Name: "orders"})
aws.SQS.SendMessage(ctx, mqdriver.SendMessageInput{
QueueURL: q.URL, Body: "order-123",
})
msgs, _ := aws.SQS.ReceiveMessages(ctx, mqdriver.ReceiveMessageInput{
QueueURL: q.URL, MaxMessages: 1,
})The Portable API also exposes batch ops, ChangeMessageVisibility, queue attributes, and PurgeQueue, which are not yet on the SDK-compat surface.