Labs / Chapter 12
The notification task, created once
Match consume to produce and confirm a young backlog. Slow the handler until age climbs. Add consumers up to the partition count, then set the claim and commit-after toggles so a redelivered message_id creates one task and loses none.
The system
A redelivery arrives with the same message_id and the handler creates another confirmation task.
process_order_event
- # produce/s = partitions = consumers = process_ms =
- def process_order_event(record, db, consumer):
- event = decode_and_validate(record.value)
- consumer.commit_next_offset(...)
- with db.transaction() as tx:
- first_delivery =
- if first_delivery:
- tx.create_notification_task(..., notification_type="order_confirmation")
- consumer.commit_next_offset(...)
- Backlog age0.0 s. Size 0 messages
- Assigned2 consumers on this topic
- This deliverySecond tasks 8/s. Lost tasks 0/s
Backlog age
Age is how late the oldest message is. Hold the oldest message under 2 seconds.
Age 0.0
The chart fills as the lab runs. s is the vertical unit.
- Age
- s
