I am trying-learning CQRS via a semi-hobby project on analyzing customer feedback. Basically you upload comments, system runs AI on it extracting sentiments, topics, statements and whatnot.
This seems like quite an easy playground to try Commanded for CQRS: things are quite asynchronous in nature, write and read activities are easy to separate and… I am not sure what to do with the command enriching moments.
User feedback needs to be passed to external API (or local process, that’s conceptually same) which can take time to execute, can fails completely and forever or can fail temporarily (API is temporarily down or I went over the hourly quota), so exponential retry is to be used several times.
I believe I understand relatively well how to do in a CRUD-like app with queues (be it Oban, Rihanna or RabbitMQ) and in the past was even doing very similar things in Java. What I am not sure about is how to mix it with CQRS. I was reading Commanded’s options on enriching via middleware or during handling the command, but can’t figure how to do retries there.
What do you do?
What do you do in similar situations when external API fails and needs to be retried?
- Are you recording an API failure by generating a “failed” event which process manager uses to generate retry command?
- Are you handling retries completely out of command processing so that e.g. middlewhere only passes the command further when all the retrying options are done even if it takes several days? And use separate queue/jobs for the retrials?
- Something completely different?