Skip to content

Conversation

@cppwfs
Copy link
Contributor

@cppwfs cppwfs commented Nov 21, 2025

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.

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.
@cppwfs cppwfs added this to the 7.0.1 milestone Nov 21, 2025
Copy link
Member

@artembilan artembilan left a 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()
Copy link
Member

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 {
Copy link
Member

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.

Copy link
Member

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.
Copy link
Member

@artembilan artembilan left a 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 {
Copy link
Member

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()

integrationFlow(publisher) {
transformWith {
transformer<Message<Int>> { it.payload * 2 }
id("foo")
Copy link
Member

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")
Copy link
Member

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
Copy link
Member

@artembilan artembilan left a 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));
Copy link
Member

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.

scatterGather -> scatterGather
.gatherTimeout(10_000));
}*/

Copy link
Member

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
}


Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intellij updated

@artembilan artembilan merged commit e6f7b6c into spring-projects:main Nov 22, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants