|
|
|
|
@@ -6,7 +6,7 @@ NOTE: The project should be treated as experimental and API is a subject to chan
|
|
|
|
|
|
|
|
|
|
The main goal we pursue here is to make Spring Integration development on Kotlin as smooth and straightforward as is it possible with interoperability with existing Java DSL and some Kotlin extensions or language-specific structures.
|
|
|
|
|
|
|
|
|
|
All you need to get started is just an import for `org.springframework.integration.dsl.integrationFlow` - an overloaded global function for Kotlin DSL.
|
|
|
|
|
All you need to get started is just an import for `org.springframework.integration.dsl.kotlin.integrationFlow` - an overloaded global function for Kotlin DSL.
|
|
|
|
|
|
|
|
|
|
For `IntegrationFlow` definitions as lambdas we typically don't need anything else from Kotlin and just declare a bean like this:
|
|
|
|
|
|
|
|
|
|
@@ -31,17 +31,16 @@ As an alternative to the construction above and for consistency with use-cases e
|
|
|
|
|
@Bean
|
|
|
|
|
fun flowLambda() =
|
|
|
|
|
integrationFlow {
|
|
|
|
|
filter<String>({ it === "test" })
|
|
|
|
|
wireTap(
|
|
|
|
|
integrationFlow {
|
|
|
|
|
handle { m -> println(m.payload) }
|
|
|
|
|
})
|
|
|
|
|
filter<String> { it === "test" }
|
|
|
|
|
wireTap {
|
|
|
|
|
handle { println(it.payload) }
|
|
|
|
|
}
|
|
|
|
|
transform<String, String> { it.toUpperCase() }
|
|
|
|
|
}
|
|
|
|
|
----
|
|
|
|
|
====
|
|
|
|
|
|
|
|
|
|
Such a global `integrationFlow()` function expects a `@BuilderInference` for a `KotlinIntegrationFlowDefinition` (a Kotlin extension for the `BaseIntegrationFlowDefinition` with some inline function for reified generic types) and produces a regular `IntegrationFlow` lambda implementation.
|
|
|
|
|
Such a global `integrationFlow()` function expects a lambda in builder style for a `KotlinIntegrationFlowDefinition` (a Kotlin wrapper for the `IntegrationFlowDefinition`) and produces a regular `IntegrationFlow` lambda implementation.
|
|
|
|
|
See more overloaded `integrationFlow()` variants below.
|
|
|
|
|
|
|
|
|
|
Many other scenarios require an `IntegrationFlow` to be started from source of data (e.g. `JdbcPollingChannelAdapter`, `JmsInboundGateway` or just an existing `MessageChannel`).
|
|
|
|
|
@@ -70,15 +69,15 @@ For example:
|
|
|
|
|
----
|
|
|
|
|
@Bean
|
|
|
|
|
fun functionFlow() =
|
|
|
|
|
integrationFlow<Function<String, String>>({ it.beanName("functionGateway") }) {
|
|
|
|
|
integrationFlow<Function<String, String>>({ beanName("functionGateway") }) {
|
|
|
|
|
transform<String, String> { it.toUpperCase() }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
fun messageSourceFlow() =
|
|
|
|
|
integrationFlow(MessageProcessorMessageSource { "testSource" },
|
|
|
|
|
{ it.poller { it.fixedDelay(10).maxMessagesPerPoll(1) } }) {
|
|
|
|
|
channel { c -> c.queue("fromSupplierQueue") }
|
|
|
|
|
{ poller { it.fixedDelay(10).maxMessagesPerPoll(1) } }) {
|
|
|
|
|
channel { queue("fromSupplierQueue") }
|
|
|
|
|
}
|
|
|
|
|
----
|
|
|
|
|
====
|
|
|
|
|
|