I have two topics
- main_topic
- retry_topic
I want if the logic fails in main_topic it should call retry_topic and if that fails so there should be max 3 retries that it should do.
I've tried using sink in faust streaming what it does is that it yield result from my main topic to retry_topic but I'm still not able to limit it to 3 retries.
Is there a way to do that in faust/kafka streaming because I know that celery has this feature.
One way to achieve that is to use headers.
Now if you want to use the same agent for two topics, before this agent you may define
topicas one ofmain_topicorretry_topic, something like this:This way you need two processes. One starts with
USE_RETRY_TOPIC = False, it reads main topic and if something goes wrong it sends a message toretry_topicafter a delay. The other process starts withUSE_RETRY_TOPIC = True, it consumes the retry topic and if something goes wrong again - sends the message to the very same topic once again, but with incrementedretriescount.You can add a condition to check the
retriescount if it is greater than3if you want.Please note that this delay logics maybe not very safe, e.g. if the process fails unexpectedly while waiting to send the message into the
retry_topic, this message might be lost.Also this approach may break the message order, link