Command Message
The order message — a clear action intent.
Problem
How to express in messaging that we want a recipient to do something? The format must be clear, identifiable, unambiguous.
Forces
- Confusing a command with a notification leads to bugs (action executed twice or never).
- Commands can fail — a rejection convention is needed.
- EDI commands are often specific message types (ORDERS, ORDCHG, ORDRSP).
Solution
Explicitly distinguish Command Message from Document/Event Message. Conventions: (1) imperative verb in the type (CreateOrder, CancelInvoice), (2) expect positive/negative acknowledgement, (3) intent identifiable in the header. In EDI: ORDERS = Command (place the order), ORDRSP = Document Response.
EDI implementation
In EDI, Command Message is typically the upstream PO message: ORDERS (EDIFACT) / 850 (X12) are commands in EIP sense — "place this order, I want these products". ORDCHG / 860 = Modify command. Implicit ORDERS-CANCEL via ORDCHG with zero quantity = Cancel command. Acknowledgement is ORDRSP / 855.
Anti-patterns
- Command Message without expected reply — sender never knows if the action succeeded.
- Multiple commands in one message without correlation — sender does not know which one failed.
- Conflating Command and Event — an INVOIC is a Document Event ("I billed"), not a Command ("bill me").
Related patterns
- Document Message — complementary pattern.
- Event Message — third style.
Sources
- Hohpe G., Woolf B. — EIP, Command Message (p. 145). www.enterpriseintegrationpatterns.com/patterns/messaging/CommandMessage.html