README.md 2.4 KB

SQS Demo with Localstack

Configuring the environment

  • install Docker
  • install Localstack.
    • On macOS: brew install localstack
  • install AWS CLI: see AWS doc
  • validate Docker configuration
    • localstack config validate

Running the demo

  • on one terminal tab:

    • start a local SQS instance
    • docker compose up
    • or docker-compose up on older Docker versions
    • you should be getting something like this:

      Attaching to localstack_main
      localstack_main  | Waiting for all LocalStack services to be ready
      localstack_main  | 2023-01-04 06:36:28,138 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
      localstack_main  | 2023-01-04 06:36:28,139 INFO supervisord started with pid 16
      localstack_main  | 2023-01-04 06:36:29,144 INFO spawned: 'infra' with pid 21
      localstack_main  |
      localstack_main  | LocalStack version: 1.3.2.dev
      localstack_main  | LocalStack Docker container id: 7ceddc18cd46
      localstack_main  | LocalStack build date: 2023-01-04
      localstack_main  | LocalStack build git hash: 8e5b4b09
      localstack_main  |
      localstack_main  | 2023-01-04 06:36:30,256 INFO success: infra entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
      localstack_main  | Ready.
      localstack_main  | 2023-01-04T06:36:30.138  WARN --- [-functhread5] hypercorn.error            : ASGI Framework Lifespan error, continuing without Lifespan support
      localstack_main  | 2023-01-04T06:36:30.138  WARN --- [-functhread5] hypercorn.error            : ASGI Framework Lifespan error, continuing without Lifespan support
      localstack_main  | 2023-01-04T06:36:30.140  INFO --- [-functhread5] hypercorn.error            : Running on https://0.0.0.0:4566 (CTRL + C to quit)
      localstack_main  | 2023-01-04T06:36:30.140  INFO --- [-functhread5] hypercorn.error            : Running on https://0.0.0.0:4566 (CTRL + C to quit)
      
  • on another terminal tab

    • create a queue: make create-queue
    • send messages: make send, which can be used repeatedly
    • list queues from Go and receive messages: go run .

Modifying the consumer

The actual consumer callback logic is in the SQS-unaware function HandleDummy in handler.go.

Feel free to modify it for other data types.

Cleaning up

After use, remove the SQS data space: make clean