Skip to content

What the NServiceBus format refuses

Note

NServiceBus licensing. NServiceBus is dual-licensed: the Reciprocal Public License 1.5, or Particular Software's commercial agreement (particular.net/LicenseAgreement). This format was captured from NServiceBus 10.2.9, and only the module's own .NET test programs use it. The Go module itself does not depend on NServiceBus.

Recognition

Recognises claims a message that has an NServiceBus.MessageId header with at least one value, in any case of the name. These cases are checked in the module's tests:

Headers Claimed
NServiceBus.MessageId with a value yes
Nservicebus.Messageid, http.Header's canonical form yes
NServiceBus.MessageId with no values no
ce-specversion only no
MessageId, MassTransit's transport mirror no
no headers no

A message that is also claimed by another format is ErrAmbiguous under envelope.Read.

On Encode

Encode fills in an empty SpecVersion and runs Validate. In v0.1.0, the released version, it returns nothing else. From the next release, of the events that are valid, it refuses only one whose type contains ;, with envelope.ErrUnrepresentable: ; separates the entries of NServiceBus.EnclosedMessageTypes, so the type would read back as its first entry (envelope-nservicebus!4). Any ID is carried, and the payload is unconstrained.

On Decode

The first problem found is returned, with the partial event and Foreign.

Error Cause
ErrAmbiguousHeader One of NServiceBus.MessageId, EnclosedMessageTypes, OriginatingEndpoint, ContentType, ce-subject, ce-dataschema or TimeSent arrives under two spellings with different values, or with two different values under one key. The error names the first of them in that order
ErrInvalidTime NServiceBus.TimeSent is not exactly yyyy-MM-dd HH:mm:ss:ffffff Z
a Validate sentinel Anything else, such as no NServiceBus.OriginatingEndpoint or no NServiceBus.EnclosedMessageTypes (ErrMissingAttribute)

The tests refuse a TimeSent in ISO 8601, with a signed microsecond, and with five digits.

Not refused

Case What happens
An ID that is not a UUID Carried as the ID
A payload of any bytes Carried as Data
No body Data is nil
The same header under two spellings with the same value Read once
A header of any other name Foreign, or an extension if the name allows
A transport content type that differs from NServiceBus.ContentType A conflict, not an error