So we've seen that NackDiscard removes a message from the primary queue, but what if we want to retry the message? As a general rule, you want to split your consumer's errors into two classes:
Logical errors: Unlikely to be resolved with a retry. For example, a message is malformed JSON, or the ID of a user doesn't exist in the database.
Transient errors: Likely to be resolved with a retry. For example, a network timeout, or a database connection error.
If you NackRequeue a message, it will be requeued to the primary queue to be processed again. This can be very bad if the error isn't transient as it will just be reprocessed over and over forever, blocking other messages and incurring large processing costs.
I call this "Requeue Hell", and I've been forged in its fires.
Only NackRequeue messages if you're confident a retry will resolve the issue!
Assignment
Let's hook up the "war" logic of Peril!
Watch as the queue freaks the hell out. You should see thousands of messages being requeued and processed over and over. It's a beautifully terrifying sight.
Run and submit the CLI tests with the madness going.
When you're done, kill your clients to stop the madness.