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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.