SQS to Database Service

This service provides API endpoints to poll messages from AWS SQS and store them in a database.

API Endpoints

1. Poll SQS Messages (Batch Processing)

POST /api/poll-sqs

Request Body

{
  "batchSize": 1000,  // Target number of messages to process (default: 1000)
  "maxMessages": 10   // Legacy parameter (ignored in batch mode)
}

Features

Response

{
  "processed": 847,           // Number of successfully processed messages
  "failed": 0,               // Number of failed messages
  "totalMessagesReceived": 847, // Total messages received from SQS
  "batchSize": 847,          // Actual batch size processed
  "message": "Successfully processed 847 messages in batch"
}

2. Get SQS Queue Statistics

GET /api/sqs-stats

Response

{
  "queueUrl": "https://sqs...",
  "approximateNumberOfMessages": 447,
  "approximateNumberOfMessagesNotVisible": 0,
  "approximateNumberOfMessagesDelayed": 0,
  "totalMessages": 447,
  "createdTimestamp": "2024-01-01T00:00:00.000Z",
  "lastModifiedTimestamp": "2024-01-01T12:00:00.000Z",
  "visibilityTimeout": 30,
  "maximumMessageSize": 262144,
  "messageRetentionPeriod": 345600,
  "delaySeconds": 0,
  "receiveMessageWaitTimeSeconds": 0,
  "timestamp": "2024-01-01T12:00:00.000Z"
}

3. Health Check

GET /api/health

Response

{
  "status": "healthy",
  "timestamp": "2024-01-01T12:00:00.000Z",
  "uptime": 3600,
  "environment": "production",
  "checks": {
    "database": "healthy",
    "sqs": "configured"
  },
  "responseTime": 45
}

Configuration

The service uses the following constants for SQS operations:

Test Scripts