Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import java.util.function.Consumer
* @property delegate the [IntegrationFlowDefinition] this instance is delegating to.
*
* @author Artem Bilan
* @author Glenn Renfro
*
* @since 5.3
*/
Expand Down Expand Up @@ -175,6 +176,17 @@ class KotlinIntegrationFlowDefinition(@PublishedApi internal val delegate: Integ
this.delegate.channel(messageChannelName)
}

/**
* Populate a [org.springframework.integration.channel.NullChannel] instance
* at the current [IntegrationFlow] chain position.
* The nullChannel acts like "/dev/null".
* @since 7.0.1
* @see org.springframework.integration.channel.NullChannel
*/
fun nullChannel() {
this.delegate.nullChannel()
}

/**
* Populate a [MessageChannel] instance
* at the current [IntegrationFlow] chain position using the [MessageChannelSpec]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
package org.springframework.integration.dsl

import assertk.assertThat
import assertk.assertions.*
import assertk.assertions.doesNotContain
import assertk.assertions.isEqualTo
import assertk.assertions.isGreaterThanOrEqualTo
import assertk.assertions.isInstanceOf
import assertk.assertions.isNotNull
import assertk.assertions.isTrue
import assertk.assertions.size
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.BeanFactory
import org.springframework.beans.factory.annotation.Autowired
Expand Down Expand Up @@ -49,13 +55,14 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig
import reactor.core.publisher.Flux
import reactor.test.StepVerifier
import java.time.Duration
import java.util.*
import java.util.concurrent.atomic.AtomicReference
import java.util.Date
import java.util.function.Function


/**
* @author Artem Bilan
* @author Glenn Renfro
*/
@SpringJUnitConfig
@DirtiesContext
Expand Down Expand Up @@ -239,6 +246,21 @@ class KotlinDslTests : TestApplicationContextAware {
registration.destroy()
}

@Autowired
private lateinit var nullCheckWireTapChannel: QueueChannel

@Autowired
@Qualifier("nullChannelWithTransformFlow.input")
private lateinit var nullChannelWithTransformFlowInput: MessageChannel

@Test
fun `nullChannel can be used after transform in a flow`() {
nullChannelWithTransformFlowInput.send(MessageBuilder.withPayload("test").build())
val tappedMessage = nullCheckWireTapChannel.receive(1000)
//verify that a message was sent, transformed and assume nullChannel discarded it.
assertThat(tappedMessage?.payload).isNotNull().isEqualTo("TEST")
}

@Configuration
@EnableIntegration
class Config {
Expand Down Expand Up @@ -386,6 +408,17 @@ class KotlinDslTests : TestApplicationContextAware {
}
}

@Bean
fun nullCheckWireTapChannel() = QueueChannel()

@Bean
fun nullChannelWithTransformFlow(
@Qualifier("nullCheckWireTapChannel") nullCheckWireTapChannel: MessageChannel) =
integrationFlow {
transform<String>{ it.uppercase() }
wireTap(nullCheckWireTapChannel)
nullChannel()
}

}

Expand Down