Choose a wire format¶
Two settings decide the format. Settings.Format writes every event the backend publishes.
Settings.Reads is the chain a received message is read with. Unset, the writer is CloudEvents
binary and the chain is CloudEvents binary then structured. The formats themselves are
go/envelope's; this page is how the adapter takes them.
The layout on the wire is in Wire formats and message layout.
Write structured¶
rabbitmq.New(rabbitmq.Settings{
URL: url, Management: mgmt, Exchange: "events",
Format: cloudevents.Structured(),
})
With cloudevents from gitlab.com/phpboyscout/go/envelope-cloudevents. The content_type
property becomes application/cloudevents+json and the attributes travel in the body.
Move a deployment from binary to structured¶
The default chain already reads structured, so upgrade the readers first and switch the writers
afterwards. A reader that sets Reads itself must include both formats for this to hold.
Read or write another format¶
For .NET services, add the format as a writer, to the read chain beside the defaults, or both:
rabbitmq.New(rabbitmq.Settings{
URL: url, Management: mgmt, Exchange: "events",
Format: masstransit.MassTransit(),
Reads: []envelope.Format{
cloudevents.Binary(cloudevents.HTTP),
cloudevents.Structured(),
masstransit.MassTransit(),
},
})
masstransit and nservicebus are gitlab.com/phpboyscout/go/envelope-masstransit and
gitlab.com/phpboyscout/go/envelope-nservicebus. Their own rules, such as MassTransit refusing an ID
that is not a UUID or a payload that is not JSON, are on their packages and surface here as a
Publish error: messaging-rabbitmq: encoding the event.
Keep the chain unambiguous¶
Exactly one format in Reads must claim a message. A message two formats claim is refused, and so
is one none claims; both are unreadable messages.
Adding a format to the chain is safe when it tells itself apart from the others by content type or
headers, as the four the suite runs do.
Setting Reads replaces the default chain: it does not add to it.
Read what no format took¶
A string header that no format takes reaches a handler as Delivery.Foreign(). It is never sent on.
The broker's own non-string entries, such as x-delivery-count and x-death, are not carried.