Skip to content

Always send a body section - #73

Open
ansd wants to merge 1 commit into
apache:mainfrom
ansd:null-body
Open

Always send a body section#73
ansd wants to merge 1 commit into
apache:mainfrom
ansd:null-body

Conversation

@ansd

@ansd ansd commented Aug 25, 2026

Copy link
Copy Markdown

Always send a body section, encoding a bodiless Message as amqp-value null.

A JMS Message created with Session.createMessage() carries no body, and the client encoded it as an AMQP message with no body section at all.

AMQP 1.0 section 3.2 does not allow that: it lists every other section as "zero or one", but the body as one of three mandatory choices (one or more data sections, one or more amqp-sequence sections, or a single amqp-value section). The AMQP JMS Mapping is explicit about which of those a bodiless JMS Message maps to - section 3.2.4.7 states that "a Message is encoded as a single amqp-value section containing null".

Brokers that enforce the requirement therefore reject every message sent by Session.createMessage(); RabbitMQ, for instance, refuses the transfer with `amqp:decode-error "missing_amqp_message_body".

Supply the amqp-value null section when encoding a facade that has no body. The fix is applied at the encode step rather than by giving the facade a body, so that the facade keeps representing "this message has no body" (as hasBody() and the JMS Message body accessors rely on) and so that a bodiless message received from a peer also gains a conformant body when forwarded.

The x-opt-jms-msg-type annotation continues to identify the message as a generic Message on receipt; without it, an amqp-value null body would be read back as a TextMessage per the mapping's section 3.3.4.

… null

A JMS Message created with Session.createMessage() carries no body, and the
client encoded it as an AMQP message with no body section at all.

AMQP 1.0 section 3.2 does not allow that: it lists every other section as
"zero or one", but the body as one of three mandatory choices (one or more
data sections, one or more amqp-sequence sections, or a single amqp-value
section). The AMQP JMS Mapping is explicit about which of those a bodiless
JMS Message maps to - section 3.2.4.7 states that "a Message is encoded as a
single amqp-value section containing null".

Brokers that enforce the requirement therefore reject every message sent by
Session.createMessage(); RabbitMQ, for instance, refuses the transfer with
amqp:decode-error "missing_amqp_message_body", which fails a range of
Jakarta Messaging TCK tests.

Supply the amqp-value null section when encoding a facade that has no body.
The fix is applied at the encode step rather than by giving the facade a
body, so that the facade keeps representing "this message has no body" (as
hasBody() and the JMS Message body accessors rely on) and so that a bodiless
message received from a peer also gains a conformant body when forwarded.

The x-opt-jms-msg-type annotation continues to identify the message as a
generic Message on receipt; without it, an amqp-value null body would be
read back as a TextMessage per the mapping's section 3.3.4.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant