We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Ack and Nack

So how does a consumer tell the message broker that an individual message succeeded or failed to be processed? When a consumer receives a message, it must acknowledge it.

If the subscriber crashes or fails to process the message, the message broker can just re-queue the message to be processed again, or discard it (perhaps to a dead-letter queue).

Nack

"Ack" is short for "acknowledge", and "Nack" is short for "negative acknowledge". There are really 3 options for acknowledging a message:

  1. Acknowledge: Processed successfully.
  2. Nack and requeue: Not processed successfully, but should be requeued on the same queue to be processed again (retry).
  3. Nack and discard: Not processed successfully, and should be discarded (to a dead-letter queue if configured or just deleted entirely).

Assignment

      • Ack
      • NackRequeue
      • NackDiscard
      • The move outcome was "safe"
      • Or, the move outcome was "make war"
      • The move outcome was "same player"
      • Or, the move outcome was anything else

Test the changes by running 2 clients: washington and napoleon. Have washington spawn a couple of units:

spawn americas artillery

Have napoleon spawn a unit:

spawn europe cavalry

Then have washington move a unit into napoleon's territory:

move europe 1

Napoleon's client should "Ack" the message, and Washington's client should "NackDiscard" the message. Make sure your logs reflect that. You can move on when you're satisfied with the results.

You might notice that nothing went to the dead-letter queue. That's because we haven't configured it yet, and that's okay.