Follow along with the Tutorial Video. It is part of your Hands-on Exercise.
When discussing messaging and streaming, it’s important to consider message ordering. Message ordering refers to:
We create the following in this lesson:
1. ConfirmationEmail.java to read messages from OrderApproved.java, simulating sending emails to customers that their order has been approved.
2. We also use ConfirmationEmail.java to check the order messages arrived at topic order_approved.

OrderProducer.java publishes orders for China to orderBackLogChina.
InventoryCheckerChina.java reads orders from topic orderBackLogChina. Since we are using an Exclusive subscription, we are guaranteed to read messages in the order they were published to topic orderBackLogChina. InventoryCheckerChina.java processes one order at a time, guaranteeing that we publish messages to topic order_approved in the same order they were received.
You created InventoryCheckerUS.java similar to InventoryCheckerChina.java. Message ordering is also guaranteed for US orders in order_approved. You should see this by executing ConfirmationEmail.java.
However, we cannot guarantee ordering across China and US orders in order_approved or order_declined because this depends on two different applications reading from two different topics (InventoryCheckerChina.java and IntentoryCheckerUS.java).
Message ordering will become more important later in the course when we discuss streaming use cases.
Create ConfirmationEmail and make edits as needed to consume from topic order_approved using subscription name confirmation_email. There is no need to produce a message from Confirmation Email. Add the following to the executions block of the pom.xml file:
<execution>
<id>confirmation_email</id>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>sn_training.dev_training.ConfirmationEmail</mainClass>
</configuration>
</execution>
The main method of ConfirmationEmail.java can now be executed using:
mvn compile exec:java@confirmation_email