Package com.babelqueue
Class EnvelopeCodec
java.lang.Object
com.babelqueue.EnvelopeCodec
Builds, encodes and decodes the canonical BabelQueue envelope — the single Java
implementation of the wire format. The shape is frozen as
{job, trace_id, data, meta, attempts} (schema version 1) so a Java
service interoperates byte-for-byte with the PHP/Laravel, Python, Go and Node
SDKs over any broker. Pure JDK — no dependencies.
Full spec: babelqueue.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe wire envelope schema version this core implements.static final StringThe value stamped intometa.langfor envelopes produced here. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanWhether a consumer should accept this envelope: rejects a missing URN, an unsupportedmeta.schema_version, missingdataor a blanktrace_id— the consumer-side counterpart to the producer JSON Schema.static EnvelopeParse a raw JSON body into anEnvelope.static StringEncode the envelope as compact UTF-8 JSON.static EnvelopefromMessage(PolyglotMessage message) Build the envelope from aPolyglotMessageon the default queue.static EnvelopefromMessage(PolyglotMessage message, String queue) Build the envelope from aPolyglotMessage.static EnvelopeBuild the canonical envelope for a(urn, data)pair on the default queue.static EnvelopeBuild the canonical envelope for a(urn, data)pair.static String
-
Field Details
-
SCHEMA_VERSION
public static final int SCHEMA_VERSIONThe wire envelope schema version this core implements.- See Also:
-
SOURCE_LANG
The value stamped intometa.langfor envelopes produced here.- See Also:
-
-
Method Details
-
make
Build the canonical envelope for a(urn, data)pair on the default queue. -
make
Build the canonical envelope for a(urn, data)pair. A fresh trace id is minted unlesstraceIdis non-blank (trace continuation);attemptsstarts at 0 andmetais stamped with a unique id, the source language, the schema version and a millisecond timestamp.- Throws:
BabelQueueException- ifurnisnullor blank
-
fromMessage
Build the envelope from aPolyglotMessageon the default queue. -
fromMessage
Build the envelope from aPolyglotMessage. If the message also implementsHasTraceIdand returns a non-empty value, that trace id is reused. -
encode
Encode the envelope as compact UTF-8 JSON. Slashes and non-ASCII are left unescaped, matching the other SDK cores; the field order is canonical. -
decode
Parse a raw JSON body into anEnvelope. Malformed or non-object input yields an empty envelope (soaccepts(com.babelqueue.Envelope)returnsfalse); theurninbound alias is resolved intojob. Does not validate the contents — callaccepts(com.babelqueue.Envelope)first. -
urn
-
accepts
Whether a consumer should accept this envelope: rejects a missing URN, an unsupportedmeta.schema_version, missingdataor a blanktrace_id— the consumer-side counterpart to the producer JSON Schema.
-