Skip to content

Orders — event contract

binding spec asyncapi/orders.asyncapi.yaml @ 3.0.0 is the spec of record. It states what must be; implementations converge on it, never the reverse.

Enforced by
  • any change must bump the artifact and service versions (check:version); a silent edit fails CI
  • a breaking change must take a major version (check:compat)
  • Spectral lint, house naming rules included
  • Microcks contract tests hold mocks and implementations to these messages
Version history
VersionFirst releasedService version
3.0.02026-08-273.0.0
2.1.02026-08-242.1.0
2.0.02026-08-232.0.0
1.5.02026-08-231.0.0
Consume it

orders.placed.v2

Emitted when an order is accepted and persisted.

sequenceDiagram
    autonumber
    participant orders as Orders
    participant chan as orders.placed.v2
    participant payments as Payments
    orders-)chan: OrderPlaced
    Note right of chan: com.hungovercoders.orders.placed.v2
    chan--)payments: OrderPlaced

OrderPlaced

Order placed

Event type com.hungovercoders.orders.placed.v2

Payload (data)

FieldTypeRequiredConstraints
order_idstring (uuid)required—
customer_idstring (uuid)required—
placed_atstring (date-time)required—
total_penceintegerrequired≥ 0
CloudEvents envelope
FieldTypeRequiredConstraints
specversionstringrequiredalways '1.0'
idstring (uuid)required—
sourcestringrequiredalways '/orders'
typestringrequiredalways 'com.hungovercoders.orders.placed.v2'
subjectstring (uuid)required—
timestring (date-time)required—
datacontenttypestringrequiredalways 'application/json'
Example events (Microcks fixtures)
placed
{
  "specversion": "1.0",
  "id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa",
  "source": "/orders",
  "type": "com.hungovercoders.orders.placed.v2",
  "subject": "11111111-1111-1111-1111-111111111111",
  "time": "2026-08-23T09:00:00Z",
  "datacontenttype": "application/json",
  "data": {
    "order_id": "11111111-1111-1111-1111-111111111111",
    "customer_id": "22222222-2222-2222-2222-222222222222",
    "placed_at": "2026-08-23T09:00:00Z",
    "total_pence": 2500
  }
}

orders.cancelled.v2

Emitted when an order is cancelled, with the reason.

sequenceDiagram
    autonumber
    participant orders as Orders
    participant chan as orders.cancelled.v2
    orders-)chan: OrderCancelled
    Note right of chan: com.hungovercoders.orders.cancelled.v2
    Note over chan: no consumer in the specs yet

OrderCancelled

Order cancelled

Event type com.hungovercoders.orders.cancelled.v2

Payload (data)

FieldTypeRequiredConstraints
order_idstring (uuid)required—
cancelled_atstring (date-time)required—
reasonstringrequiredone of customer_request, payment_failed, out_of_stock
CloudEvents envelope
FieldTypeRequiredConstraints
specversionstringrequiredalways '1.0'
idstring (uuid)required—
sourcestringrequiredalways '/orders'
typestringrequiredalways 'com.hungovercoders.orders.cancelled.v2'
subjectstring (uuid)required—
timestring (date-time)required—
datacontenttypestringrequiredalways 'application/json'
Example events (Microcks fixtures)
cancelled
{
  "specversion": "1.0",
  "id": "bbbbbbbb-2222-4222-8222-bbbbbbbbbbbb",
  "source": "/orders",
  "type": "com.hungovercoders.orders.cancelled.v2",
  "subject": "33333333-3333-3333-3333-333333333333",
  "time": "2026-08-23T09:05:00Z",
  "datacontenttype": "application/json",
  "data": {
    "order_id": "33333333-3333-3333-3333-333333333333",
    "cancelled_at": "2026-08-23T09:05:00Z",
    "reason": "customer_request"
  }
}

Full rendered contract