liveBook · Manning

Message broker

As explained in Data Pipelines with Apache Airflow, Second Edition

A broker is a message-queue component that receives, stores, and delivers messages between producers and consumers.

When Airflow uses the CeleryExecutor to run tasks across multiple machines, its scheduler needs a queue through which workers can receive tasks. Celery calls this queue a broker. The scheduler sends messages to it, and Celery workers wait for tasks to arrive. section 15.2.3

Figure 15.3 In the CeleryExecutor, tasks are divided among multiple machines running Celery workers. The workers wait for tasks to arrive in a queue.
A screenshot of a computer

AI-generated content may be incorrect.

The diagram shows tasks distributed among machines running Celery workers, with workers waiting on a queue. section 15.2.3

To connect Airflow to a broker:

  • Install the Celery dependencies and select the executor: `pip install 'apache-airflow[celery]'` and `AIRFLOW__CORE__EXECUTOR=CeleryExecutor`. section 15.2.3
  • Install a Celery-supported queueing system, then set `AIRFLOW__CELERY__BROKER_URL` to its URI. Redis, RabbitMQ, and AWS SQS are supported options in this setup. section 15.2.3
  • Configure `AIRFLOW__CELERY__RESULT_BACKEND` separately so workers can communicate with the Airflow metastore. Make the DAGs folder available to workers at the path set by `AIRFLOW__CORE__DAGS_FOLDER`. section 15.2.3

Redis broker

Set `AIRFLOW__CELERY__BROKER_URL=redis://localhost:6379/0`. After starting the Airflow API server, scheduler, and a worker with `airflow celery worker`, trigger a DAG manually. A successfully completed task validates the path through the CeleryExecutor components. The Redis URI is a broker address, not a substitute for the separately configured result backend. section 15.2.3

A queue can also carry external events: a message published on a message bus may be a reason to trigger a DAG. That use is distinct from the CeleryExecutor broker’s role in distributing Airflow tasks to workers. section 7.0 section 15.2.3

How Data Pipelines with Apache Airflow, Second Edition covers it

How deep it goes
Explains broker URL configuration and deployment checks, but leaves broker installation and queue-specific URI formats to external documentation.
Examples
Uses Redis and RabbitMQ broker URLs, a worker startup command, and a manually triggered DAG as a validation check.
What it assumes
Assumes an installed broker and worker access to DAG files; does not teach broker installation.
What you can do after
Operate/configure it by setting a broker URL, connecting the result backend, starting workers, and validating task completion.
How it connects
Connects message queues with the CeleryExecutor, scheduler, Celery workers, result backend, and external-event DAG triggers.

Also explained in

Compare how 3 books explain message broker →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Pipelines with Apache Airflow, Second Edition. The section links point to the parts of the book it draws on.