-
Notifications
You must be signed in to change notification settings - Fork 1.1k
.log() should always behave the same, no matter where it is placed in a flow #3615
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
Comments
Thank you for your report and such a great problem explanation, @swiss-chris ! We definitely keep our users in mind when we develop an API like this Java DSL, but indeed I missed that principle from the start. Saying that I would like to share with you our journey how we came up with So, you are not the first who bumped his/her head against this Here is my suggestion (which is not different from yours):
In general we are pursuing the same behavior as it would be even without Any further comments are welcome! (Sorry for late reply: was on vacation) |
Hi Artem |
I also need your opinion on this and if we are in an agreement, WDYT about deprecating Thanks |
Yes; it sounds reasonable, but not clear how you can deprecate, unless you say deprecated in favor of |
If it is an explicit Taking back my deprecation suggestion for the current version even if we will live with it in |
@artembilan Is this still scheduled for inclusion in 6.0 ? |
Same here: it is in plan for the current |
Fixes spring-projects#3615 The `log()` operator for Java DSL in the end of flow causes a confusion for its different behavior and, therefore, inconsistency with expectations * Populate a `bridge()` in the end of flow instead of `nullChannel` when the current component is `WireTapSpec` (relevant to `wireTap()` and `log()`) * Deprecate a `logAndReply()` operator since its behavior is now included into the `log()` in the end if flow * Fix tests to use just `log()` in the end from now on * Fix `dsl.adoc` for the new `log()` behaviour in the end of flow
Fixes #3615 The `log()` operator for Java DSL in the end of flow causes a confusion for its different behavior and, therefore, inconsistency with expectations * Populate a `bridge()` in the end of flow instead of `nullChannel` when the current component is `WireTapSpec` (relevant to `wireTap()` and `log()`) * Deprecate a `logAndReply()` operator since its behavior is now included into the `log()` in the end if flow * Fix tests to use just `log()` in the end from now on * Fix `dsl.adoc` for the new `log()` behaviour in the end of flow
Uh oh!
There was an error while loading. Please reload this page.
Expected Behavior
Given some code like this:
if I move the
.log()
statement down one line, like this:I would expect everything to work exactly the same, except that the
.log()
statement is executed after the.gateway()
call.Current Behavior
Changing the position of
.log()
changes the behavior of the flow. In this case, the releaseStrategy never receives the output of the second recipientFlow. The reason for this is explained in the JavaDoc, where we read - "When this operator is used in the end of flow, it is treated as one-way handler without any replies to continue.".Context
This is not the behavior one would expect, it's not intuitive, and it has caused an unexpected bug in our team that took a long time to debug. (https://en.m.wikipedia.org/wiki/Principle_of_least_astonishment) We were quite surprised to learn about
.logAndReply()
and consider it one of those things that make the SI DSL hard to work with. Sometimes things just don't work and you have not reason why and no easy and no quick way to find the cause.IMO the
.log()
statement should behave the same no matter where you place it in a flow. If it is placed at the end of a flow, and if this flow has no output channel, throw the usual exception, and the developer will quickly realize they need to add.nullChannel()
or something similar. Perhaps you could even detect if.log()
needs to reply or not (it seems you can detect if it is at the end of a flow, so maybe at that moment you can also detect if an output channel is configured for this flow) ?logAndReply()
could be deprecated and ultimately removed.Am I missing something that would prevent such a solution ?
The text was updated successfully, but these errors were encountered: