@allmhhuran 100% agree! Not they are not casually connected. However, let me give an example
Say we have multiple stores and each store is at least 60 minutes away from each other. Say the events are generated by each store per customer. It’s impossible that customer would be located physically in two stores and generating events such as (register customer, purchase item, etc).
Given that, say
app 1 (Store 1) generated E1 and E2 per Customer ID
app 2 (Store 2) generated E3 and E4 per Same Customer ID
My Listener (Subscriber) will run on a scheduler based say every 5 minutes, pull the messages grouped by Customer ID
Listener #1/Scheduler #1:
- Run #1: Pull message E1 and E2 and assign timestamp then send them to Topic (T1 - for customer 123) → /stores/events/customers/123
- Run #2: could be irrelevant to this customer
Listener #2/Scheduler #2:
- Run #1: Pull message E3 and E4 and assign timestamp then send them to Topic (T1 - same customer 123) → /stores/events/customers/123
- Run #2: could be irrelevant to this customer
In this case, we guarantee that this topic has received in order. Even in case of scheduler delay with strong monitoring and management, we guarantee that Scheduler won’t be that late
However, those events are published and persisted by timestamp in case of failure to convoy them to the other side due to internet connectivity issue or latency or may be E1 and E2 had a race condition in the middle of the flow that let E2 win first. Then we have timestamp to control them again sequentially.
Does this make sense?