Questions:
- How can we ensure our duplicate handling works correctly?
- What should we do first, persist or publish?
Questions:
- Do you see duplicates detected?
- There are messages indicating errors in processing that we have not seen in Exercise 1. Why?
- These error messages are logged at
INFO
level by the framework (NServiceBus). Why?
Follow up:
- Modify the duplicating behavior to duplicate only
AddItem
messages that are of typeMeat
.- Use
context.Message.Instance
in theInvoke
method to get access to the outgoing message payload - Remember to check the type before trying to cast the payload object to specific type
- Use
Questions:
- Has
Billing
receive theItemAdded
notification? - Has the state in the
Orders
endpoint changed? - Is state of the system consistent?
Conclusion: Must not leak not state changes that have not been made persistent
Questions:
- Have all events arrived at the
Billing
endpoint? Why? - How can we solve it?
Conclusion: Must re-public messages if publishing failed
Questions:
- What is the state of the system? What did you expect it to be?
- Why is the state inconsistent?
- How can we fix it?
Conclusion: The idempotence of each operation by itself is not enough if operations can be interleaved
Questions:
- Did it work?
- Why do we need to use the same
DbContext
in the de-duplication behavior and the handler? - Why did the downstream endpoint receive a duplicate message?
- Can the downstream endpoint de-duplicate? How?
Conclusion: We need outgoing message ID generation logic to be deterministic
Questions:
- Why do we need the name of the processing endpoint?
Questions:
- Was the event published?
- What is the problem?
Conclusion: The logic for generating outgoing messages needs to be based on the version of the state that was current at the time the message has initially been processed, not on the incoming message
Conclusion 2: It is damn hard to achieve
Questions:
- How do we make sure that if we fail after the first
SaveChanges
but before dispatching the dispatching is re-tried until succeeds? - Can we use a different DB context in the de-duplicating behavior and in the handler?