Skip to content

MessageHistory does not copy the original message when handling an errormessage #3843

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

Closed
emagiz opened this issue Jul 12, 2022 · 1 comment · Fixed by #3854
Closed

MessageHistory does not copy the original message when handling an errormessage #3843

emagiz opened this issue Jul 12, 2022 · 1 comment · Fixed by #3854
Assignees
Milestone

Comments

@emagiz
Copy link

emagiz commented Jul 12, 2022

In what version(s) of Spring Integration are you seeing this issue?

5.5.11

Describe the bug

MessageHistory does not copy the original message when handling an errormessage.
When we use messagehistory in an integration flow the original message in the errormessage is always null. When we do not use messagehistory the originalmessage in the errormessage is not null and corresponds to the originalmessage.

Code part here:

ErrorMessage errorMessage = new ErrorMessage(payload, headerAccessor.toMessageHeaders());

To Reproduce

Add messagehistory to any flow producing an error.
Flow details:
<si:channel fixed-subscriber="false" id="tstrrr.rrrmssg.entry.channel.channel"/>
<si:inbound-channel-adapter channel="tstrrr.rrrmssg.entry.channel.channel" expression="'hallo'" id="tstrrr.rrrmssg.entry.receive.InboundError">

<si:poller fixed-delay="5" time-unit="SECONDS"/>
</si:inbound-channel-adapter>
<si:service-activator input-channel="tstrrr.rrrmssg.entry.channel.channel" expression="payload[10]" id="tstrrr.rrrmssg.entry.activate.serviceActivator" requires-reply="false"/>

We are listening for errors and then checking by using this:
System.out.println("IS ORIGINAL MESSAGE NULL? :" + (message.getOriginalMessage() == null));

Expected behavior
The original message is copied along to the new message

Sample

			IntegrationMessageHeaderAccessor headerAccessor = new IntegrationMessageHeaderAccessor(message);
			headerAccessor.setHeader(HEADER_NAME, history);
			Throwable payload = ((ErrorMessage) message).getPayload();
			Message originalMessage = ((ErrorMessage) message).getOriginalMessage();
			ErrorMessage errorMessage = new ErrorMessage(payload, headerAccessor.toMessageHeaders(), originalMessage);
			message = (Message<T>) errorMessage;
@emagiz emagiz added status: waiting-for-triage The issue need to be evaluated and its future decided type: bug labels Jul 12, 2022
@artembilan artembilan added in: core backport 5.5.x and removed status: waiting-for-triage The issue need to be evaluated and its future decided labels Jul 12, 2022
@artembilan artembilan added this to the 6.0.0-M4 milestone Jul 12, 2022
@artembilan
Copy link
Member

Confirmed.

Would you mind providing a contribution on the matter: https://github.com/spring-projects/spring-integration/blob/main/CONTRIBUTING.adoc ?

Thanks

artembilan added a commit to artembilan/spring-integration that referenced this issue Jul 18, 2022
Fixes spring-projects#3843

The `MessageHistory.write()` is missing the `ErrorMessage.originalMessage`
on creating a new `ErrorMessage` with message history header

* Reuse an `ErrorMessage.originalMessage` for newly created `ErrorMessage`
after populating the message history header

**Cherry-pick to `5.5.x`**
@artembilan artembilan self-assigned this Jul 18, 2022
garyrussell pushed a commit that referenced this issue Jul 18, 2022
Fixes #3843

The `MessageHistory.write()` is missing the `ErrorMessage.originalMessage`
on creating a new `ErrorMessage` with message history header

* Reuse an `ErrorMessage.originalMessage` for newly created `ErrorMessage`
after populating the message history header

**Cherry-pick to `5.5.x`**
garyrussell pushed a commit that referenced this issue Jul 18, 2022
Fixes #3843

The `MessageHistory.write()` is missing the `ErrorMessage.originalMessage`
on creating a new `ErrorMessage` with message history header

* Reuse an `ErrorMessage.originalMessage` for newly created `ErrorMessage`
after populating the message history header

**Cherry-pick to `5.5.x`**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants