Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -103,6 +103,18 @@ class GroovyIntegrationFlowDefinition {
this
}

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

/**
* Populate a {@link org.springframework.integration.dsl.support.MessageChannelReference} instance
* at the current {@link IntegrationFlow} chain position.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,35 @@ class GroovyDslTests {
assert groovyTestService.result.get() == 'TEST'
}

@Autowired
@Qualifier('nullChannelFlow.input')
private MessageChannel nullChannelFlowInput

@Autowired
private MessageChannel nullCheckWireTapChannel


@Test
void 'nullChannelFlow discards messages'() {
nullChannelFlowInput.send MessageBuilder.withPayload('test').build()
def tappedMessage = nullCheckWireTapChannel.receive(1000)

//verify that a message was sent and assume nullChannel discarded it.
assert tappedMessage?.payload == 'test'
}

@Autowired
@Qualifier('nullChannelWithTransformFlow.input')
private MessageChannel nullChannelWithTransformFlowInput

@Test
void 'nullChannel can be used after transform in a flow'() {
nullChannelWithTransformFlowInput.send MessageBuilder.withPayload('test').build()
def tappedMessage = nullCheckWireTapChannel.receive(1000)
//verify that a message was sent, transformed and assume nullChannel discarded it.
assert tappedMessage?.payload == 'TEST'
}

@Configuration(proxyBeanMethods = false)
@EnableIntegration
static class Config {
Expand Down Expand Up @@ -361,6 +390,30 @@ class GroovyDslTests {

}

@Bean
nullChannelFlow(@Qualifier('nullCheckWireTapChannel') MessageChannel nullCheckWireTapChannel) {
integrationFlow {
wireTap(nullCheckWireTapChannel)
nullChannel()
}
}

@Bean
nullChannelWithTransformFlow(@Qualifier('nullCheckWireTapChannel') MessageChannel nullCheckWireTapChannel) {
integrationFlow {
transform {
transformer { it.toUpperCase() }
}
wireTap(nullCheckWireTapChannel)
nullChannel()
}
}

@Bean
MessageChannel nullCheckWireTapChannel() {
new QueueChannel()
}

}

@CompileStatic
Expand Down