Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

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