87 lines
3.0 KiB
Markdown
87 lines
3.0 KiB
Markdown
# NGCloud SQS — Managed Message Queue Service
|
|
|
|
Совместимый с Amazon SQS сервис очередей сообщений на базе [ElasticMQ](https://github.com/softwaremill/elasticmq).
|
|
|
|
## Демо-стенд
|
|
|
|
| | |
|
|
|---|---|
|
|
| **Web UI** | https://sqs.kube5s.ru/ |
|
|
| **SQS Endpoint** | `https://sqs.kube5s.ru/sqs/test001` |
|
|
| **Access Key** | `SQSAK-test001-ae4dc8` |
|
|
| **Secret Key** | `J8mElXq8Nwww8iFRtGJCm8KfxM9XSTluTqS2A67xsEE` |
|
|
| **Region** | `us-east-1` (любая) |
|
|
|
|
## Быстрый тест (curl)
|
|
|
|
### Создать очередь
|
|
```bash
|
|
curl -s -u "SQSAK-test001-ae4dc8:J8mElXq8Nwww8iFRtGJCm8KfxM9XSTluTqS2A67xsEE" \
|
|
"https://sqs.kube5s.ru/sqs/test001?Action=CreateQueue&QueueName=myqueue&Version=2012-11-05"
|
|
```
|
|
|
|
### Отправить сообщение
|
|
```bash
|
|
curl -s -u "SQSAK-test001-ae4dc8:J8mElXq8Nwww8iFRtGJCm8KfxM9XSTluTqS2A67xsEE" \
|
|
"https://sqs.kube5s.ru/sqs/test001?Action=SendMessage&QueueUrl=https://sqs.kube5s.ru/sqs/test001/test001/myqueue&MessageBody=HelloWorld&Version=2012-11-05"
|
|
```
|
|
|
|
### Получить сообщение
|
|
```bash
|
|
curl -s -u "SQSAK-test001-ae4dc8:J8mElXq8Nwww8iFRtGJCm8KfxM9XSTluTqS2A67xsEE" \
|
|
"https://sqs.kube5s.ru/sqs/test001?Action=ReceiveMessage&QueueUrl=https://sqs.kube5s.ru/sqs/test001/test001/myqueue&Version=2012-11-05"
|
|
```
|
|
|
|
## Python (boto3)
|
|
|
|
```python
|
|
import boto3
|
|
|
|
sqs = boto3.client(
|
|
"sqs",
|
|
endpoint_url="https://sqs.kube5s.ru/sqs/test001",
|
|
region_name="us-east-1",
|
|
aws_access_key_id="SQSAK-test001-ae4dc8",
|
|
aws_secret_access_key="J8mElXq8Nwww8iFRtGJCm8KfxM9XSTluTqS2A67xsEE",
|
|
)
|
|
|
|
# Создать очередь
|
|
queue = sqs.create_queue(QueueName="myqueue")
|
|
print(queue["QueueUrl"])
|
|
|
|
# Отправить сообщение
|
|
sqs.send_message(QueueUrl=queue["QueueUrl"], MessageBody="Hello from Python!")
|
|
|
|
# Получить сообщение
|
|
msgs = sqs.receive_message(QueueUrl=queue["QueueUrl"])
|
|
print(msgs["Messages"][0]["Body"])
|
|
```
|
|
|
|
## Node.js (@aws-sdk/client-sqs)
|
|
|
|
```js
|
|
const { SQSClient, CreateQueueCommand, SendMessageCommand, ReceiveMessageCommand } = require("@aws-sdk/client-sqs");
|
|
|
|
const sqs = new SQSClient({
|
|
endpoint: "https://sqs.kube5s.ru/sqs/test001",
|
|
region: "us-east-1",
|
|
credentials: {
|
|
accessKeyId: "SQSAK-test001-ae4dc8",
|
|
secretAccessKey: "J8mElXq8Nwww8iFRtGJCm8KfxM9XSTluTqS2A67xsEE",
|
|
},
|
|
});
|
|
|
|
const queue = await sqs.send(new CreateQueueCommand({ QueueName: "myqueue" }));
|
|
await sqs.send(new SendMessageCommand({ QueueUrl: queue.QueueUrl, MessageBody: "Hello!" }));
|
|
const res = await sqs.send(new ReceiveMessageCommand({ QueueUrl: queue.QueueUrl }));
|
|
console.log(res.Messages[0].Body);
|
|
```
|
|
|
|
## Особенности
|
|
|
|
- Полная совместимость с Amazon SQS API (AWS SDK работает без изменений — только endpoint меняется)
|
|
- Физическая изоляция: каждый тенант получает отдельный pod, namespace, диск
|
|
- Persistence: данные сохраняются при перезапуске
|
|
- Web UI для визуального управления очередями
|
|
|