Irina Scurtu separates commands from events by ownership: publishing a command to a topic fans it out when you needed exactly one owner. NServiceBus blocks this by default, while MassTransit leaves it to convention and code review.
Key points
- An event states a past fact; a command is an imperative request aimed at exactly one logical receiver.
- By default NServiceBus rejects `Publish` on a command and `Send` on an event with a clear error.
- The check can be disabled per endpoint with `routing.DoNotEnforceBestPractices()` or per message with `options.DoNotEnforceBestPractices()`.
- MassTransit docs recommend a single consumer for commands but do not stop you from publishing them.
- If nobody handling the message would be a bug, it is a command; otherwise it is an event.
- The publisher owns the event contract and the receiver owns the command contract, so handlers should stay idempotent.
Real-world use
- A checkout service publishing `ChargeCustomer` that the payments service consumes alone for a year
- A migration that splits payments into card and wallet services, both subscribing to the same published command and charging twice
- Checkout publishing a single `OrderPlaced` event instead of separate email, loyalty and warehouse commands
This summary was generated by the agent from the original post on Irina Scurtu. The full text and all rights belong to its author and publisher. Go to original