Code Monkey home page Code Monkey logo

django-sqs-celery-template's Introduction

django-sqs-celery-template

An effortlessly pre configured Django, Celery and SQS template repository for those who want to process asynchronous background tasks.

Getting started

Requirements

Before running this app we will need:

Running locally (docker-compose)

Inside the cloned repository folder:

  1. Copy the .env.example
cp .env.example .env
  1. Build and run the app:
docker-compose up

That's it! After building and running the app your should have 5 container services available on your machine. Now you can start developing your application and your async background tasks!

Testing it

For the local environment you can test receiving a message on the queue according to the following steps.

  • Launch a bash terminal within the web container with:
docker exec -it <docker_web_id> bash
  • Open the django shell:
python src/manage.py shell_plus
  • Import the task and execute it:
from payment.tasks import capture_payment
capture_payment.delay(pk=10)

You should see the worker docker service logs changing and a new message on the queue named "celery" if you access the panel on: http://localhost:9325

There is also the possibility of testing it through the aws-cli. To do that you need to add a new queue to the config/elasticmq.conf file because the celery queue expects the data on a specific format.

queues {
   default {
     defaultVisibilityTimeout = 10 seconds
     delay = 5 seconds
     receiveMessageWait = 0 seconds
   }
}

And now you can test it:

aws --endpoint-url http://localhost:9324 sqs send-message --queue-url http://localhost:9324/queue/default --message-body "Hello, queue"

django-sqs-celery-template's People

Contributors

rodolfolottin avatar dependabot[bot] avatar miguelzetina avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.