Skip to content

Help decoding multiple messages using rust by resolving #987#991

Merged
mjpt777 merged 3 commits intoaeron-io:masterfrom
wbprime:987-help-decoding-multiple-messages-using_rust
Oct 25, 2024
Merged

Help decoding multiple messages using rust by resolving #987#991
mjpt777 merged 3 commits intoaeron-io:masterfrom
wbprime:987-help-decoding-multiple-messages-using_rust

Conversation

@wbprime
Copy link
Contributor

@wbprime wbprime commented Apr 24, 2024

Closes #987

Say multiple messages were encoded into a continuous byte buffer. When trying to decode the first message, we might first use a MessageHeaderDecoder to get its templateId at offset=0, then decode its body using correspoded message decoder at offset+=headerLength. This is ok for current message decoder's header method with an implicit header offset=0. But when trying to decoder the second and following messages, the MessageHeaderDecoder step is ok however the body decoding step using header method would fetch bytes always from the first message body, thus is not expected.

This unexpected result occurs only when using message decoder's header method to gain ownership. Use message decoder's wrap method behaves as expected.

This pr is just a simple workaround, simple but works (see tests/issue_987_test.rs).

Elvis Wang added 3 commits April 24, 2024 20:42
When decoding multiple messages from a single byte buffer, the second
and following message decoder should offset to the new header offset
plus header length.
@mward
Copy link
Contributor

mward commented Oct 24, 2024

Thanks @wbprime, I think this looks good. Can someone apply this PR?

@mjpt777 mjpt777 merged commit e34fc03 into aeron-io:master Oct 25, 2024
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.

[Rust] cumulate offset of header and message_header_codec::ENCODED_LENGTH in generated Decoder::header method

3 participants