forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
integration.groovy
39 lines (32 loc) · 940 Bytes
/
integration.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package org.test
@Configuration
@EnableIntegration
class SpringIntegrationExample implements CommandLineRunner {
@Autowired
private ApplicationContext context
@Bean
DirectChannel input() {
new DirectChannel()
}
@Override
void run(String... args) {
println()
println '>>>> ' + new MessagingTemplate(input()).convertSendAndReceive("World", String) + ' <<<<'
println()
/*
* Since this is a simple application that we want to exit right away,
* close the context. For an active integration application, with pollers
* etc, you can either suspend the main thread here (e.g. with System.in.read()),
* or exit the run() method without closing the context, and stop the
* application later using some other technique (kill, JMX etc).
*/
context.close()
}
}
@MessageEndpoint
class HelloTransformer {
@Transformer(inputChannel="input")
String transform(String payload) {
"Hello, ${payload}"
}
}