Question: Delayed retry queue implementation in Faust?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 10/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- kafka, python
- Lĩnh vực
- stream-processing
Hướng nghiên cứu
The payload points to Consumer.pause_partitions and Consumer.resume_partitions in faust.transport.base, which the reporter says never reach the underlying AIOKafkaConsumer, so the partitions keep delivering messages. Start by tracing those two methods to see whether they touch the aiokafka consumer at all. Done would be a documented way to delay reprocessing without hitting max_poll_interval, which is a design decision for maintainers, not a clear code change.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi,
I'm trying to implement a delayed retry queue using Kafka and Faust.
The idea is that after failing to process a message it gets forwarded to an RQ topic.
Messages consumed from this topic aren't immediately reprocessed as a delay is applied first.
A more detailed description of this approach can be found here and here.
I've managed to come up with a working Aiokafka implementation but struggle to implement this pattern in Faust (which is the library used in the app I need to add the queue to).
In Aiokafka I use the pause / resume consumer api. After consuming a message I pause the partitions assigned to the consumer.
To not exceed the limit of max_poll_interval_ms a separate asyncio task gets created which handles the delay and reprocessing.
This task sleeps for the given delay time during which the context can be switched to consumer loop.
The loop doesn't return any new messages due to paused partitions but polls Kafka so max_poll_interval_ms isn't reached.
After reprocessing the message is committed and consumer partitions are re-enabled:
async def consume(topic: str, bootstrap_servers: str, group_id: str) -> None:
consumer = AIOKafkaConsumer(
topic,
bootstrap_servers=bootstrap_servers,
group_id=group_id,
enable_auto_commit=False, # will manually commit each message
max_poll_interval_ms=1000, # only 1s delay between poll required
)
await consumer.start()
try:
async for message in consumer:
consumer.pause(*consumer.assignment())
create_task(delayed_processing(consumer, message, 60)) # delay by 60s from message.timestamp
finally:
await consumer.stop()
async def delayed_processing(consumer: AIOKafkaConsumer, message: ConsumerRecord, delay: int) -> None:
try:
processing_delay = get_message_processing_delay(message, delay)
await asyncio.sleep(processing_delay)
run_processing(message)
await consumer.commit()
finally:
consumer.resume(*consumer.assignment())
I think that the Faust implementation should follow the same pattern (it uses aiokafka under the hood) but I can't manage to have the stream paused / resumed after consuming a message.
When I use the provided pause_partitions and resume_partitions api methods the max_poll_interval is reached (they don't seem to touch the AIOKafka consumer in any way).
When I use the underlying AIOKafkaConsumer thread to pause the consumer in the same manner as above, the event
stream keeps on giving me new messages anyway.
Do you know of a way to implement this pattern using Faust or maybe Faust requres a different approach?
Checklist
- I have included information about relevant versions
- I have verified that the issue persists when using the
masterbranch of Faust.
Versions
- Python version: 3.10
- Faust version: 0.10.4
- Operating system
- Kafka version
- RocksDB version (if applicable)
- Ngôn ngữ chính
- Python
- Star
- 1.9k
- Fork
- 205
- Merge trung bình
- 2 giờ 2 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của faust-streaming/faust
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
faust-streaming/faust#804 ·
-
scripts/install script forces use of ./venv virtualenv, impossible to use with virtualenvwrapperĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
faust-streaming/faust#28 · 1 bình luận ·
-
[BUG] SASL PLAINTEXT producer initialization fails : missing sasl_plain_username/passwordCó thể đã có người làm @wbarnha đã nhận 56 ngày trước. Đang mở
faust-streaming/faust#794 · 2 bình luận · 1 reaction · 2 người được giao ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
faust-streaming/faust#670 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
faust-streaming/faust#666 ·
Tất cả issue của faust-streaming/faust
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Maintainer] task area:visualizer
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
RailtownAI/railtracks#1824 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
apache/datafusion#27688 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
heasarc/heasarc-tutorials#317 ·
-
bug good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
mloda-ai/mloda-registry#1664 ·
Maintainer thường phản hồi trong vòng 1 ngày