Replies: 1 comment
|
Don't use the container hostname as the durable consumer identity. A new For a shared Taskiq worker pool, one documented alternative is a pull-based broker with a stable durable name: from taskiq_nats import PullBasedJetStreamBroker
broker = PullBasedJetStreamBroker(
servers=settings.NATS_URL,
durable="my-task-workers", # Stable across restarts and worker replicas.
).with_result_backend(result_backend=result_backend)Use the same stream/subject configuration and durable name for workers that are meant to share the queue. The taskiq-nats README documents In your push configuration, setting Existing hostname-based consumers and stream data remain server-side after changing the Python configuration. Inspect their pending/acknowledged state before retiring obsolete consumers, and decide which backlog the stable consumer should process. Don't use repeated container pruning as the queue-state fix. NATS explains how durable consumers retain their reading position. Finally, keep only one scheduler publishing a given label schedule unless you explicitly coordinate multiple schedulers. Check whether one scheduled tick produces multiple messages or one message is being delivered repeatedly; those require different fixes. Stable consumers solve the identity/replay issue, but JetStream can still redeliver unacknowledged work, so task side effects should remain idempotent. |
Uh oh!
There was an error while loading. Please reload this page.
I have fastapi application + taskiq with nats jetstream.
running with docker compose
To make the application run correctly in the broker settings I specify durable_name=f “consumer-{socket.gethostname()}” otherwise I get the error consumer name already in use. I guess that because of this at some point schedules start to run multiple times. During the first run of docker compose everything works as expected, but the next times the number of schedules starts to increase. The docker container prune solves this for one run, but then it happens again. What can I do in this situation?
All reactions