Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ddceea6

Browse files
Merge pull request #3 from SimpleProgramming/develop
spring integration example
2 parents bb20486 + b6a6f42 commit ddceea6

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

‎springboot-integration-router/src/main/java/com/springboot/config/IntegrationConfig.java‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
import org.springframework.context.annotation.Configuration;
88
import org.springframework.integration.annotation.Filter;
99
import org.springframework.integration.annotation.IntegrationComponentScan;
10+
import org.springframework.integration.annotation.ServiceActivator;
1011
import org.springframework.integration.annotation.Transformer;
1112
import org.springframework.integration.channel.DirectChannel;
1213
import org.springframework.integration.config.EnableIntegration;
1314
import org.springframework.integration.core.MessageSelector;
1415
import org.springframework.integration.filter.MessageFilter;
1516
import org.springframework.integration.json.JsonToObjectTransformer;
1617
import org.springframework.integration.json.ObjectToJsonTransformer;
18+
import org.springframework.integration.router.PayloadTypeRouter;
1719
import org.springframework.integration.support.json.Jackson2JsonObjectMapper;
1820
import org.springframework.integration.transformer.HeaderEnricher;
1921
import org.springframework.integration.transformer.support.HeaderValueMessageProcessor;
@@ -22,6 +24,7 @@
2224
import org.springframework.messaging.MessageChannel;
2325

2426
import com.fasterxml.jackson.databind.ObjectMapper;
27+
import com.springboot.model.Address;
2528
import com.springboot.model.Student;
2629

2730
@Configuration
@@ -33,12 +36,13 @@ public class IntegrationConfig {
3336
public MessageChannel recieverChannel() {
3437
return new DirectChannel();
3538
}
36-
37-
// @Bean
38-
// public MessageChannel replyChannel() {
39-
// return new DirectChannel();
40-
// }
4139

40+
// @Bean
41+
// public MessageChannel replyChannel() {
42+
// return new DirectChannel();
43+
// }
44+
45+
//Filter Example
4246
@Filter(inputChannel = "router.channel")
4347
@Bean
4448
public MessageFilter filter() {
@@ -52,7 +56,8 @@ public boolean accept(Message<?> message) {
5256
filter.setOutputChannelName("student.channel");
5357
return filter;
5458
}
55-
59+
60+
//Transformer Example
5661
@Bean
5762
@Transformer(inputChannel = "integration.student.gateway.channel", outputChannel = "integration.student.toConvertObject.channel")
5863
public HeaderEnricher enrichHeader() {
@@ -80,4 +85,15 @@ public Jackson2JsonObjectMapper getMapper() {
8085
JsonToObjectTransformer jsonToObjectTransformer() {
8186
return new JsonToObjectTransformer(Student.class);
8287
}
88+
89+
// PayloadTypeRouter Example
90+
@ServiceActivator(inputChannel = "router.channel")
91+
@Bean
92+
public PayloadTypeRouter payloadRouter() {
93+
PayloadTypeRouter router = new PayloadTypeRouter();
94+
router.setChannelMapping(Student.class.getName(), "student.enrich.header.channel");
95+
router.setChannelMapping(Address.class.getName(), "address.enrich.header.channel");
96+
return router;
97+
}
98+
8399
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /