Course Setup
Use Case
Messaging Basics
Consumer Subscription Types
API Internals for Message Integrity and Scaling
1 of 3

Hands-on Exercise: Message Ordering

Complete the following for your Hands-on Exercise:

  • Follow the tutorial for consuming messages from topic order_approved by creating ConfirmationEmail.java.
  • Start ConfirmationEmail.java and OrderProducer.java.
  • Start InventoryCheckerChina.java.  Notice that all of the messages are processed from inventoryBackLogChina, written to order_approved or order_declined, and then consumed by ConfirmationEmail.java from order_approved.
  • Start InventoryCheckerUS.java.  Notice that all of the messages are processed from inventoryBackLogUS, written to order_approved or order_declined, and then consumed by ConfirmationEmail.java from order_approved.

Ordering is guaranteed within China orders and within US orders due to their Exclusive subscriptions.  However, message ordering across China and US orders is not guaranteed.  Prove this by observing the output of ConfirmationEmail.java.

Here is an example output when executing IntentoryCheckerUS followed by InventoryCheckerChina after orders have been produced. The messages are no longer in order.

Handling message: 1US
Handling message: 3US
Handling message: 5US
Handling message: 7US
Handling message: 1US
Handling message: 3US
Handling message: 5US
Handling message: 7US
Handling message: 9US
Handling message: 11US
Handling message: 13US
Handling message: 15US
Handling message: 17US
Handling message: 19US
Handling message: 4China
Handling message: 6China
Handling message: 4China
Handling message: 6China
Handling message: 8China
Handling message: 10China
Handling message: 14China
Handling message: 16China
Handling message: 18China