Skip to content
/ sqsproxyd Public

sqsproxy is an application that imitates SQS daemon provided in the AWS Elastic Beanstalk worker environment. In addition, it has the ability to forward a response to another SQS.

License

Notifications You must be signed in to change notification settings

ohke/sqsproxyd

Repository files navigation

sqsproxyd

Release Docker Hub CI

sqsproxyd is SQS proxy daemon.

This is an application that imitates SQS daemon (sqsd) provided in the AWS Elastic Beanstalk worker environment. In addition, it has the ability to send a response (= forward) to another SQS.

Architecture

Features

  • Receive (dequeue) a message from SQS and make a POST request to the specified API.
  • If the API returns a success response (HTTP status: 2**), removes the message from the SQS.
  • [Optional] If an output SQS is set, the API success response body be sent (enqueued) to that SQS as a message.

Why does sqsproxyd implement response forwarding?

The purpose is to make it easy to build a microservice architecture system using SQS. By completely hiding the SQS input and output in sqsproxyd (and its configuration), application developers can focus on implementing the API.

Usage

Execution

Command-line (binary)

The binaries can be downloaded here.

$ sqsproxyd \
  --sqs-url https://sqs.us-west-1.amazonaws.com/123456789012/sqsproxyd-sqs \
  --api-url http://localhost:4000/api 

Docker container

The sqsproxyd container image can also be pulled from Docker Hub.

$ docker pull ohke/sqsproxyd
$ docker run ohke/sqsproxyd \
  --sqs-url https://sqs.us-west-1.amazonaws.com/123456789012/sqsproxyd-sqs \
  --api-url http://localhost:4000/api
How can I use sqsproxyd images with AWS ECS or Kubernetes?

Please, see examples.

Configuration

Either method can be used to pass parameters. If a value exists for both, command-line arguments take precedence.

  • Environment variables
  • Command-line arguments

Parameters

Command-line argument Environment variable Required Default Description
--aws-access-key-id AWS_ACCESS_KEY_ID no - Your AWS access key ID
--aws-secret-access-key AWS_SECRET_ACCESS_KEY no - Your AWS secret access key
--aws-session-token AWS_SESSION_TOKEN no - Your AWS session token
--aws-region SQSPROXYD_AWS_REGION or AWS_DEFAULT_REGION no - Your AWS region name
--aws-endpoint SQSPROXYD_AWS_ENDPOINT no - To use mock SQS (like alpine-sqs)
--sqs-url SQSPROXYD_SQS_URL yes - SQS URL to input
--api-url SQSPROXYD_API_URL yes - API URL to POST request
--output-sqs-url SQSPROXYD_OUTPUT_SQS_URL no - SQS URL to forward response message
--num-workers SQSPROXYD_NUM_WORKERS no 1 Number of concurrent workers
--api-timeout-msec SQSPROXYD_API_TIMEOUT_MSEC no 30000 API connection timeout milliseconds
--sleep-msec SQSPROXYD_SLEEP_MSEC no 1000 Interval milliseconds of receiving when retrieving 0 message
--api-health-url SQSPROXYD_API_HEALTH_URL no - API health check URL to GET request
--api-health-interval-seconds SQSPROXYD_API_HEALTH_INTERVAL_SECONDS no 1 Interval seconds of request health check endpoint
--content-type SQSPROXYD_CONTENT_TYPE no application/json Content-type header of API request
--rust-log SQSPROXYD_RUST_LOG no WARN Application logging directive

Contribution

Development

Prerequisites

Install followings.

Clone and build

$ git clone https://github.com/ohke/sqsproxyd.git
$ cd sqsproxyd
$ cargo build

Run with mock SQS, API

$ cp ./env/local.env ./.env
$ direnv allow
$ docker-compose up -d sqsproxyd-sqs sqsproxyd-api
$ cargo run

License

sqsproxyd is available under the Apache-2.0 open source license.

About

sqsproxy is an application that imitates SQS daemon provided in the AWS Elastic Beanstalk worker environment. In addition, it has the ability to forward a response to another SQS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published