Class Codecs
Formats are discovered rather than listed, for the same reason transports are: the core cannot depend on an XML library, an Avro library and a Protobuf library at once, and should not try. Each format is a module that announces itself, and asking for one that is not there produces an error naming the artifact to add rather than a missing class.
The defaults are deliberately asymmetric. Publishing uses JSON and nothing else, because a queue carrying two formats at once is a queue no consumer can be written against, and the format on the wire is a contract with services that are not being redeployed. Consuming uses every codec on the classpath, because a consumer that refuses a message it could have read has turned somebody else's deployment into its own outage.
Write one format, read all of them. That asymmetry is what makes changing format two ordinary releases instead of a flag day.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe format published in unless the application says otherwise. -
Method Summary
Modifier and TypeMethodDescriptionstatic Codecstringis accepted as another name fortext, which stays the canonical one: it is what the .NET and Ruby libraries call the same codec, and a name copied from one of them should not fail here.static CodecEvery codec on the classpath, in the order they should be tried.static Codecnames()
-
Field Details
-
DEFAULT_FORMAT
The format published in unless the application says otherwise.- See Also:
-
-
Method Details
-
byName
stringis accepted as another name fortext, which stays the canonical one: it is what the .NET and Ruby libraries call the same codec, and a name copied from one of them should not fail here.- Parameters:
name- short format name, such asjsonorxml- Returns:
- a codec for that format
- Throws:
AceMqException- if no module on the classpath provides it
-
forPublishing
- Returns:
- the codec used to publish when the application has not chosen one
-
forConsuming
Every codec on the classpath, in the order they should be tried.What a consumer reads with. A message that names its format goes to the codec that claims it; a message that names none is offered to each in turn, which is the only useful answer when a sender has told us nothing.
- Returns:
- a codec that reads any known format and writes the default one
-
names
- Returns:
- the format names available on this classpath, in the order they are tried
-