⏱ 8 min read
A command with no owner is a request nobody has to answer.
Publish-subscribe exists to broadcast events: the sender puts a message on a topic, the broker hands a copy to every interested consumer, and the sender never needs to know who they are.
But a topic doesn't check what kind of message you put on it. OrderPlaced or ChargeCustomer, it carries whatever bytes you give it. So publishing a command works. In my opinion, it's also the shortcut that leads teams into their first double charge.
I can't emphasize this enough: there is a fine line between a command and an event(at least in when you start with async messaging), and I keep hearing about teams that walk right over it.
An event says something already happened. OrderPlaced. PaymentReceived. Past tense, because it's a fact and you can't argue with it. The publisher owns the contract. It decides what the event looks like, and it doesn't care who listens. Zero subscribers, one, or twelve - the publisher's job ended when the order was placed and the event message goes out.
A command says "do this". ChargeCustomer. CreateOrder. Imperative, because it's a request, and a request that shouldn't be refused. The receiver should own the contract, because the receiver is the one who knows how to do that specific work. And there is exactly one logical receiver. The sender cares a lot that someone acts on it. That's the whole reason it sent the message.
The tense on the name is only a hint. What separates the two is who is responsible. Events move responsibility away from the sender. Commands hand it to one specific owner.
Publishing means "whoever subscribed/is interested gets a copy". That's great when the sender doesn't care who reacts. For a command, it breaks the one thing you needed: a single owner.
Here's how it goes wrong. Your checkout service publishes ChargeCustomer. The payments service subscribes. Everything works for a year.
Then someone splits payments into a card service and a wallet service. During the migration both subscribe to ChargeCustomer, because both know how to charge. Each one gets its own copy, and each one charges. The customer pays twice, and no code "failed". The broker did exactly what you asked: it delivered a published message to every subscriber.
The opposite failure is quieter. The payments team renames their endpoint, or a subscription gets dropped during a deployment. Now ChargeCustomer goes out with zero subscribers. On most brokers that means the message vanishes. No error, no dead-letter entry, no exception in the sender. Orders ship and nobody pays for them until finance asks why the numbers don't match.
With a send, both of those are loud. You send to a specific queue. If the queue doesn't exist, the send fails. If a second service wants to handle the command, it has to become the owner. Two teams have to talk about that before it happens.

In NServiceBus, the verb is the decision:
// A request with one owner
await context.Send(new ChargeCustomer(orderId, amount));
// A fact, for whoever cares
await context.Publish(new OrderPlaced(orderId, customerId));
NServiceBus goes further and enforces it. The docs on messages, events, and commands say a command "should be sent to the logical owner" and "cannot be subscribed to", while an event "should be published by the logical owner". Get it wrong and it throws. Publish a command and you get:
"Pub/Sub is not supported for Commands. They should be sent directly to their logical owner."
Send an event and you get:
"Events can have multiple recipients so they should be published."
This enforcement is on by default. You can switch it off per endpoint with routing.DoNotEnforceBestPractices() or per message with options.DoNotEnforceBestPractices(). If you find yourself reaching for either, stop and ask which message you are really sending.
MassTransit is more relaxed. Its message docs use the same vocabulary: a command "tells a service to do something, and typically a command should only be consumed by a single consumer", while events "are published (using Publish)". But the docs also say commands may be published and will be routed to the consumer. Nothing stops you. So I treat it as a convention you enforce in code review: Send to an endpoint for commands, Publish for events.
Sometimes a published command is a sign the message is named wrong.
If checkout publishes SendConfirmationEmail, UpdateLoyaltyPoints and NotifyWarehouse, checkout knows far too much about the rest of the system. Flip it. Checkout publishes OrderPlaced and stops there. The email service, the loyalty service and the warehouse each decide what OrderPlaced means to them. That's the decoupling pub/sub promised in the first place.
If you can't flip it, because the sender needs one specific thing to happen and needs to know it did, then it's a command. Send it. If the sender also needs an answer back, pub/sub won't give it one. The channels are one-way, so you want request-reply.
A useful test: if nobody handles this message, is that a bug? If yes, it's a command. If no, it's an event.
There are a few cases where I'd skip pub/sub altogether:
Notice how many of these describe commands in disguise. "I need an answer now" and "it must happen exactly once as part of my transaction" are things a sender says about work it depends on. I wrote about the saga side of this in When Business Processes Outlive Your Request: the orchestrator sends commands and reacts to events, and it never mixes the two up.
Ownership shows up again when messages change.
For events, the publisher owns the contract, so versioning is the publisher's job. Prefer additive changes like new optional fields, and for breaking changes, version through the topic name (orders.v1, orders.v2) or a version field in the metadata. Subscribers should ignore fields they don't recognise. That last rule is what lets a publisher add a field on Tuesday without coordinating a release with five teams.
For commands, it's the other way around. The receiver owns the contract, and senders adapt to it. If payments needs a currency code on ChargeCustomer, payments decides that, and every sender updates. Publish a command and this breaks too: which of the unknown subscribers gets to define the contract?
ChargeCustomer) and events in the past tense (CustomerCharged). If a name doesn't fit either, you don't know yet what the message is.Pub/sub is a great way to tell the world something happened. It's a terrible way to make sure one thing gets done, because it deliberately doesn't know who is listening.
The broker will carry your commands. It just won't tell you who picked them up, or that nobody did.
PS: have you been bitten by a published command, or a sent event? Ping me, I'd love to hear the story.
publish-subscribe commands-vs-events cloud-design-patterns message-contracts nservicebus masstransit
Hi! Welcome to my blog
.NET, messaging, and distributed systems - the trade-offs the docs leave out.
Form not loading? Subscribe here.