You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
942 B
Groovy
40 lines
942 B
Groovy
11 years ago
|
package org.test
|
||
|
|
||
11 years ago
|
@Configuration
|
||
|
@EnableIntegration
|
||
11 years ago
|
class SpringIntegrationExample implements CommandLineRunner {
|
||
|
|
||
11 years ago
|
@Autowired
|
||
|
private ApplicationContext context;
|
||
|
|
||
11 years ago
|
@Bean
|
||
|
DirectChannel input() {
|
||
|
new DirectChannel();
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
@Override
|
||
|
void run(String... args) {
|
||
11 years ago
|
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()),
|
||
9 years ago
|
* or exit the run() method without closing the context, and stop the
|
||
11 years ago
|
* application later using some other technique (kill, JMX etc).
|
||
|
*/
|
||
|
context.close()
|
||
11 years ago
|
}
|
||
|
}
|
||
|
|
||
|
@MessageEndpoint
|
||
|
class HelloTransformer {
|
||
|
|
||
|
@Transformer(inputChannel="input")
|
||
|
String transform(String payload) {
|
||
|
"Hello, ${payload}"
|
||
|
}
|
||
|
|
||
11 years ago
|
}
|