Building a message bus
For this section, we will be using the Celery
and Redis
packages to build and run our message bus. Once we have completed this section, our mechanism will take a form that is similar to the following:
As shown in the preceding diagram, we have two processes running. One is running our Flask application, while the other is running Celery
, which handles queuing and processing tasks. To make this work, we are going to perform the following steps:
- Build a
Celery
broker for Flask. - Build a Fibonacci calculation task for Celery.
- Update our calculation view with
Celery
. - Define our
Celery
service in Docker.
Before we embark on these steps, we have to install the following packages using pip
:
Celery
: This is the message bus broker that we are going to use.Redis
: This is the storage system thatCelery
is going to use.
Now that we have installed...