Unless I'm misunderstanding, it sounds like your use case fits RabbitMQ perfectly. Pseudocode:
while True:
message = queue.consume()
process(message)
message.ack()
RabbitMQ will automatically put the message back on the queue when the consumer that pulled it disconnects w/o acknowledging it first. Alternatively, you could explicitly reject messages: while True:
message = queue.consume()
try:
process(message)
except Exception:
message.reject()
raise
If you're using Python you might want to check out Dramatiq[1][1]: https://dramatiq.io