spring – Java: check whether the task from RabbitMQ was completed within the specified timeout

I have a microservice Spring app: the 1st module (Producer) pushes tasks to certain Rabbit queues, then other modules (Consumers) process tasks and push message with result (SUCCESS, ERORR (with desc)) to queue that the Producer listens to. After receiving a message about the result, the Producer saves it to the DB.

Now I want to implement the function of setting a timeout to tasks when creatin:

  1. If the task was not completed within the specified timeout, the restart method should be called
  2. If the task was completed with an error within the specified timeout, then the restart method should also be called.
    I would be grateful for any ideas, links, articles and so on.

Read more here: Source link