cloudevents / spec

CloudEvents Specification
https://cloudevents.io
Apache License 2.0
5.1k stars 586 forks source link

How to deal with multiple data sections in AMQP? #1275

Closed deissnerk closed 7 months ago

deissnerk commented 7 months ago

The AMQP spec states:

The body consists of one of the following three choices: one or more data sections, one or more amqp-sequence sections, or a single amqp-value section.

If I understand the AMQP binding for CloudEvents correctly, we only make use of the data section and not the amqp-sequence or the amqp-value, but how are multiple data sections supposed to be treated? Should an implementation always only consider the first, or should multiple data sections be concatenated?

@clemensv

embano1 commented 7 months ago

FWIW, sdk-go uses github.com/Azure/go-amqp which itself in GetData() returns the first data slice of Data [][]byte

deissnerk commented 7 months ago

Thanks, I am currently experimenting with Rust and there the Body is defined as an enum where Data essentially is TransparentVec<ByteBuf>. So I was wondering what the reasoning behind allowing multiple data segments in an AMQP message is, and if we need some clarification for the AMQP binding.

deissnerk commented 7 months ago

@embano1 We discussed this on last week's call. It seems that all data sections of a message need to be concatenated. I suppose that in practice, it does not occur often, but a message might span multiple AMQP frames. I'm not deeply familiar with these details of the AMQP protocol, but I assume that the possibility of having multiple data sections is exactly for this case. I opened an issue on github.com/Azure/go-amqp for clarification.

embano1 commented 7 months ago

Thx, keep us posted, because might require changes to our SDK(s)

deissnerk commented 7 months ago

@embano1 I got an answer. For details, please refer to the issue linked above.

embano1 commented 7 months ago

@deissnerk FYI https://github.com/cloudevents/sdk-go/pull/1034

deissnerk commented 7 months ago

My initial question has been answered. Multiple data sections are simply a feature of AMQP, but semantically it remains one payload of the message. Therefore, concatenating seems to be the right behavior.