Skip to content

GH-7925: Make message history header as mutable #8980

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
merged 2 commits into from
Mar 5, 2024

Conversation

artembilan
Copy link
Member

Fixes: #7925

The MessageHistory.write() creates not only a new instance of the MessageHistory, but also a new copy of the whole message.
This significantly impacts the performance when we have too many components to track

  • Make MessageHistory as append-only container and create a new instance (plus message) only on the first track when no prior history is present
  • Change WireTap, BroadcastingDispatcher, AbstractMessageRouter and AbstractMessageSplitter to use a new AbstractIntegrationMessageBuilder.cloneMessageHistoryIfAny() API for every branch a message is produced.
    Essentially, create a new message with copy of the message history to let that downstream sub-flow have its own trace
  • Modify failed unit tests for a new logic where message history header is not immutable anymore
  • This also fixes an AbstractMessageSplitter for propagating its track into messages it emits

Fixes: spring-projects#7925

The `MessageHistory.write()` creates not only a new instance of the `MessageHistory`,
but also a new copy of the whole message.
This significantly impacts the performance when we have too many components to track

* Make `MessageHistory` as append-only container and create a new instance (plus message)
only on the first track when no prior history is present
* Change `WireTap`, `BroadcastingDispatcher`, `AbstractMessageRouter` and `AbstractMessageSplitter`
to use a new `AbstractIntegrationMessageBuilder.cloneMessageHistoryIfAny()` API for every branch a message
is produced.
Essentially, create a new message with copy of the message history to let that downstream sub-flow
have its own trace
* Modify failed unit tests for a new logic where message history header is not immutable anymore
* This also fixes an `AbstractMessageSplitter` for propagating its track into messages it emits
@artembilan artembilan requested review from sobychacko and onobc March 4, 2024 22:32
NOTE: Prior to version 6.3, the message history header was immutable (you cannot re-write history): every single track created not only new instance of the `MessageHistory`, but a fully new message copy.
Now it works in append-only mode: the first track creates a new message with a new `MessageHistory` container.
All the rest `MessageHistory.write()` calls add new entries to existing header - and no new message created.
This significantly improves an application performance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this instead of an?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what is this application in this context.
My thought was about any application which uses message history.
Maybe you meant the instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ya, i meant the. sorry.

Now it works in append-only mode: the first track creates a new message with a new `MessageHistory` container.
All the rest `MessageHistory.write()` calls add new entries to existing header - and no new message created.
This significantly improves an application performance.
All the components in the framework, where same message can be sent to several consumers (`PublishSubscribeChannel`, `AbstractMessageRouter`, `WireTap` etc.) (or splitter produces several outputs based on input message), are now cloning an existing `MessageHistory` header into those new messages.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the need for the parenthesis around the sentence, or splitter produces.... Also or where splitter produces...?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it OK to have several where in the sequence?
I mean we already have one where in the beginning.
This or is just one more in the sequence.
So, might just no parenthesis and that's it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya, thats fine.

@sobychacko
Copy link
Contributor

@artembilan Looks great based on our code walkthrough. Some very minor nit-picks on the docs. That's all.

@artembilan artembilan requested a review from sobychacko March 5, 2024 18:11
@artembilan
Copy link
Member Author

@sobychacko ,

The build is 🟢 .
If you agree with my latest optimization, feel free to merge.

Thanks

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.

Consider a Mechanism to Avoid Message Rebuilding on Every Track [INT-3983]
2 participants