Spring Integration는 dsl 형태로 message flow을 구성할 수 있는 편리한 빌더들과 API를 제공한다.
org.springframework.Integration.dsl 패키지에는 IntegrationFlowBuilder API와 여러 IntegrationComponentSpec 구현체가 포함되어 있으며, 이러한 구현은 빌더이기도 하며 구체적인 엔드포인트를 구성할 수 있는 유연한 API를 제공한다.
IntegrationFlowBuilder 인프라는 채널, 엔드포인트, 폴러 및 채널 인터셉터와 같은 메시지 기반 응용프로그램을 위한 공통 EIP(Enterprise Integration Patter)를 제공한다.
엔드포인트는 가독성을 향상시키기 위해 dsl에서 동사로 표현된다. EIP 엔드포인트를 사용하는 dsl 메서드로 정의했다
transform → Transformer
filter → Filter
handle → ServiceActivator
split → Splitter
aggregate → Aggregator
route → Router
bridge → Bridge
참고 자료 엔드포인트 용어에 대한 개념 정의
@Bean
fun myFlow(): IntegrationFlow? {
return IntegrationFlows.from("input")
.filter { anObject: Any? -> "World".equals(anObject) }
.transform { str: String -> "Hello $str" }
.handle { x: Message<*>? -> println(x) }
.get()
}
abstract class PollingChannelAdapter<T>(
private val pollingChannelPageConfiguration: PollingChannelPageConfiguration
): IntegrationObjectSupport(), MessageSource<List<T>> {
@Value("\${spring.application.name}")
private lateinit var appName: String
lateinit var time: PollingChannelTimeConfiguration
override fun receive(): Message<List<T>> {
......
return message
}
@Bean
fun myFlow(): IntegrationFlow? {
return IntegrationFlows.from([InputChannelAdapterObject])
.filter { anObject: Any? -> "World".equals(anObject) }
.transform { str: String -> "Hello $str" }
.handle { x: Message<*>? -> println(x) }
.get()
}