Skip to main content
taskiq logo

taskiq

v1.13.0 Apache-2.0

z4j-taskiq ยท Upstream project

Broker-agnostic async task framework.

taskiq's value is broker-flexibility (Redis, NATS, AMQP). z4j-taskiq rides taskiq's broker-independent layer, which has no portable cancel or retry primitive, so it ships the universal submit_task plus reconcile path. Event capture via Z4JTaskiqMiddleware.

Latest
v1.13.0
Released
2026-10-19
License
Apache-2.0

Install

bash
pip install z4j-taskiq

Native actions

  • submit_task

Not supported

  • cancel_task (taskiq has no broker-agnostic cancel primitive)
  • retry_task
  • bulk_retry
  • requeue_dead_letter
  • list_dead_letters
  • purge_queue
  • restart_worker
  • rate_limit

These are engine-level limitations: the underlying engine does not expose the primitives required to support these actions.

Wiring

How z4j plugs in

Event capture

Z4JTaskiqMiddleware: pre_send / pre_execute / post_execute / on_error.

Reconciliation

result_backend.is_result_ready() + get_result(). Works across every backend taskiq ships.

Install

Add z4j to a taskiq app

z4j itself is one container or one Python process. The agent is a pip package in your app's environment that opens one outbound connection to it.

taskiq is an async-native task queue with first-class FastAPI ergonomics, suited to teams who want a modern async Python stack end to end. z4j-taskiq instruments the broker and worker without touching your task code.

1. Run z4j

bash
pip install z4j && z4j serve

First boot prints a setup URL to stderr. Open it, create the first admin, and mint a token and HMAC secret for the agent. Docker and PostgreSQL setups are in the install guide.

Django + taskiq

2. Install the agent

bash
pip install z4j-django[taskiq]

3. Wire it into Django

python
# settings.py
INSTALLED_APPS += ["z4j_django"]

Z4J = {
    "brain_url":   env("Z4J_BRAIN_URL"),
    "token":       env("Z4J_TOKEN"),
    "hmac_secret": env("Z4J_HMAC_SECRET"),
    "project_id":  env("Z4J_PROJECT_ID"),
    "agent_name":  env("Z4J_AGENT_NAME", default=None),
}
# z4j-django discovers only Celery in the web process; the taskiq
# worker process needs its own hook (see below).

Task lifecycle events come from the taskiq worker process, which needs the z4j-taskiq worker hook. Full guide: Django integration and taskiq engine docs.

Flask + taskiq

2. Install the agent

bash
pip install z4j-flask[taskiq]

3. Wire it into Flask

python
from flask import Flask
from z4j_flask import Z4J

app = Flask(__name__)
app.config["TASKIQ_BROKER"] = "myapp.broker:broker"
z4j = Z4J(app)  # reads Z4J_* from the environment or app.config["Z4J_*"]

Task lifecycle events come from the taskiq worker process, which needs the z4j-taskiq worker hook. Full guide: Flask integration and taskiq engine docs.

FastAPI + taskiq

taskiq mirrors FastAPI's dependency-injection style, the lifespan hooks line up naturally, and z4j-taskiq captures broker, worker and result events without changing your task definitions.

2. Install the agent

bash
pip install z4j-fastapi[taskiq]

3. Wire it into FastAPI

python
from myapp.broker import broker  # your TaskIQ broker
from fastapi import FastAPI
from z4j_fastapi import z4j_lifespan

# The engine handle registers the taskiq adapter in the web process.
app = FastAPI(
    lifespan=z4j_lifespan(
        taskiq_broker=broker,
    ),
)

Task lifecycle events come from the taskiq worker process, which needs the z4j-taskiq worker hook. Full guide: FastAPI integration and taskiq engine docs.

taskiq in a plain Python worker

2. Install the agent

bash
pip install z4j-bare z4j-taskiq

3. Start it at worker boot

python
# The module that defines your broker (before the TaskIQ CLI starts it)
from taskiq_redis import ListQueueBroker
from z4j_bare import install_agent
from z4j_taskiq import TaskiqEngineAdapter, attach_to_broker

broker = ListQueueBroker("redis://localhost:6379")
adapter = TaskiqEngineAdapter(broker=broker)
attach_to_broker(broker, adapter=adapter)
runtime = install_agent(engines=[adapter])

Full guide: Plain Python integration and taskiq engine docs.

Scheduler

taskiq scheduler with z4j

Dashboard management for TaskIQ label schedules.

taskiq scheduler runs its schedules as taskiq tasks. Wraps the actual stock LabelScheduleSource with persistent dashboard overrides. It rechecks cached definitions before dispatch and preserves edits and pauses across producer restart.

What z4j can do with taskiq scheduler

  • List schedules
  • Create schedule
  • Update schedule
  • Delete schedule
  • Enable / disable
  • Trigger-now

Limitations

  • Requires matching z4j package versions, TaskIQ 0.13+ and the source's owning event loop
  • Managed writes support the stock label source; custom sources retain their existing extension points
  • Registered task labels determine routing; preserve the override file

Package z4j-taskiqscheduler. Reference: taskiq scheduler docs. For schedules edited from the dashboard on any engine, see z4j-scheduler; every option side by side is on the schedulers overview.

Included

What you get on top of taskiq

  • Persistent taskiq task history in PostgreSQL or SQLite
  • Task controls the adapter advertises, and nothing it cannot execute safely
  • Issues: repeated failures grouped by fingerprint
  • RBAC with invitations and password reset
  • HMAC-chained audit log of operator actions
  • Notifications: email, Slack, Telegram, webhook
License

The agent packages (z4j-taskiq and the framework adapters) are Apache 2.0. Importing them into your app does not affect its licensing. z4j itself is AGPL-3.0-or-later and runs in its own process.

More engines

Other z4j engines

Try z4j with taskiq