-
Notifications
You must be signed in to change notification settings - Fork 5.1k
CAMEL-22549: Replace deprecated Exchange getOut/hasOut/setOut with getMessage API #22358
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
base: main
Are you sure you want to change the base?
Changes from all commits
537501c
76860ab
b6889f7
ea607bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| import org.apache.camel.ExchangePattern; | ||
| import org.apache.camel.Expression; | ||
| import org.apache.camel.ExpressionIllegalSyntaxException; | ||
| import org.apache.camel.Message; | ||
| import org.apache.camel.NoSuchBeanException; | ||
| import org.apache.camel.Predicate; | ||
| import org.apache.camel.RuntimeCamelException; | ||
|
|
@@ -368,15 +369,17 @@ private static Object invokeBean(BeanHolder beanHolder, String beanName, String | |
| // force to use InOut to retrieve the result on the OUT message | ||
| resultExchange.setPattern(ExchangePattern.InOut); | ||
| processor.process(resultExchange); | ||
| // the response is always stored in OUT | ||
| result = resultExchange.hasOut() ? resultExchange.getOut().getBody() : null; | ||
| // the bean component creates an OUT for non-void methods on OUT-capable exchanges, | ||
| // so getResponse() returns null for void methods (no result) and the OUT for non-void | ||
| Message response = ExchangeHelper.getResponse(resultExchange); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pattern E: The bean component only creates an OUT for non-void methods on OUT-capable exchanges. |
||
| result = response != null ? response.getBody() : null; | ||
|
|
||
| // propagate properties and headers from result | ||
| if (resultExchange.hasProperties()) { | ||
| exchange.getProperties().putAll(resultExchange.getProperties()); | ||
| } | ||
| if (resultExchange.hasOut() && resultExchange.getOut().hasHeaders()) { | ||
| exchange.getIn().getHeaders().putAll(resultExchange.getOut().getHeaders()); | ||
| if (response != null && response.hasHeaders()) { | ||
| exchange.getIn().getHeaders().putAll(response.getHeaders()); | ||
| } | ||
|
|
||
| // propagate exceptions | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pattern B:
in.copy()replacesgetOut()+ manual header propagationThe old code did:
Now
in.copy()both creates the OUT and propagates headers in one step. The guard!hasResponse(exchange)avoids overwriting if an OUT already exists from an earlier processor in the chain.Claude Code on behalf of Guillaume Nodet