-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add nullChannel() to Kotlin DSL
#10601
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
Add nullChannel() to Kotlin DSL
#10601
Conversation
This commit adds support for `nullChannel()` in the Kotlin DSL, mirroring the functionality recently added to the Groovy DSL. The `nullChannel()` method populates a NullChannel instance at the current IntegrationFlow chain position, acting like "/dev/null" to discard messages. Two test cases verify the functionality: - Messages sent to a flow ending with `nullChannel()` are discarded - Transform operations can precede `nullChannel()` in a flow This enhancement provides feature parity between the Kotlin and Groovy DSLs for null channel support.
artembilan
left a comment
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.
Would you mind fixing also that sample in the kotlin-dsl.adoc removing MessageProcessorMessageSource?
| fun nullChannelFlow(@Qualifier("nullCheckWireTapChannel") nullCheckWireTapChannel: MessageChannel) = | ||
| integrationFlow { | ||
| wireTap(nullCheckWireTapChannel) | ||
| nullChannel() |
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.
I think we don't need this bean and respective test.
Looks like the another one covers this functionality pretty well.
| fun nullChannelWithTransformFlow( | ||
| @Qualifier("nullCheckWireTapChannel") nullCheckWireTapChannel: MessageChannel) = | ||
| integrationFlow { | ||
| transformWith { |
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.
Looks like simple inline fun <reified P : Any> transform(crossinline function: (P) -> Any) { would do exactly what we have here so far.
That id is out of use anyway.
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.
OK.
I mean just this instead:
transform<String>{ it.uppercase() }
In other words:
transform<String>{ it.uppercase() }
wireTap(nullCheckWireTapChannel)
nullChannel()
* nullChannelWithTransformFlow is satisfactory * Simplify transformer declaration for the transformer null test * Replace import <>.* with proper package names * Remove unused id's in all transforms used by tests * Remove commented code. Users can find this in the docs.
artembilan
left a comment
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.
Any chances for the doc fix we have discussed before?
| fun nullChannelWithTransformFlow( | ||
| @Qualifier("nullCheckWireTapChannel") nullCheckWireTapChannel: MessageChannel) = | ||
| integrationFlow { | ||
| transformWith { |
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.
OK.
I mean just this instead:
transform<String>{ it.uppercase() }
In other words:
transform<String>{ it.uppercase() }
wireTap(nullCheckWireTapChannel)
nullChannel()
spring-integration-core/src/test/kotlin/org/springframework/integration/dsl/KotlinDslTests.kt
Show resolved
Hide resolved
| integrationFlow(publisher) { | ||
| transformWith { | ||
| transformer<Message<Int>> { it.payload * 2 } | ||
| id("foo") |
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.
I know foo is bad but that is not what we want to do in this test configuration removing id.
The point is to have coverage for API.
Removing it everywhere was not a request.
If you worry about coverage more, then we might modify respective test to check for presence of bean with that name.
Thanks
| log<Any>(LoggingHandler.Level.WARN) { it.payload } | ||
| transformWith { | ||
| expression("payload") | ||
| id("spelTransformer") |
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.
DITTO here: no removal.
My request was to use just transform<String>{ it.uppercase() } in your new bean, not id removal.
* ReAdd commented code set and description * Update DsL for transform
artembilan
left a comment
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.
Fix for the kotlin-dsl.adoc, please?
| .stream() | ||
| .anyMatch(m -> (Double) m.getPayload() > 5)), | ||
| scatterGather -> scatterGather | ||
| .gatherTimeout(10_000)); |
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.
Something is off with reformatting this code snippet: it became unreadable.
spring-integration-core/src/test/kotlin/org/springframework/integration/dsl/KotlinDslTests.kt
Show resolved
Hide resolved
| scatterGather -> scatterGather | ||
| .gatherTimeout(10_000)); | ||
| }*/ | ||
|
|
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.
However, it must stick to the bean it is related to.
This is so that it is associated with the proper code
| } | ||
|
|
||
|
|
||
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.
We probably don't have Checkstyle running against Kotlin code but, please, confirm that there are no trailing spaces in this line.
You can configure your IDEA to remove them on file save.
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.
Intellij updated
This commit adds support for
nullChannel()in the Kotlin DSL, mirroring the functionality recently added to the Groovy DSL. ThenullChannel()method populates a NullChannel instance at the current IntegrationFlow chain position, acting like "/dev/null" to discard messages.Two test cases verify the functionality:
nullChannel()are discardednullChannel()in a flowThis enhancement provides feature parity between the Kotlin and Groovy DSLs for null channel support.