Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.annotation.Filter;
import org.springframework.integration.annotation.IntegrationComponentScan;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.annotation.Transformer;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.config.EnableIntegration;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.filter.MessageFilter;
import org.springframework.integration.json.JsonToObjectTransformer;
import org.springframework.integration.json.ObjectToJsonTransformer;
import org.springframework.integration.router.PayloadTypeRouter;
import org.springframework.integration.support.json.Jackson2JsonObjectMapper;
import org.springframework.integration.transformer.HeaderEnricher;
import org.springframework.integration.transformer.support.HeaderValueMessageProcessor;
Expand All @@ -22,6 +24,7 @@
import org.springframework.messaging.MessageChannel;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.springboot.model.Address;
import com.springboot.model.Student;

@Configuration
Expand All @@ -33,12 +36,13 @@ public class IntegrationConfig {
public MessageChannel recieverChannel() {
return new DirectChannel();
}

// @Bean
// public MessageChannel replyChannel() {
// return new DirectChannel();
// }

// @Bean
// public MessageChannel replyChannel() {
// return new DirectChannel();
// }

//Filter Example
@Filter(inputChannel = "router.channel")
@Bean
public MessageFilter filter() {
Expand All @@ -52,7 +56,8 @@ public boolean accept(Message<?> message) {
filter.setOutputChannelName("student.channel");
return filter;
}


//Transformer Example
@Bean
@Transformer(inputChannel = "integration.student.gateway.channel", outputChannel = "integration.student.toConvertObject.channel")
public HeaderEnricher enrichHeader() {
Expand Down Expand Up @@ -80,4 +85,15 @@ public Jackson2JsonObjectMapper getMapper() {
JsonToObjectTransformer jsonToObjectTransformer() {
return new JsonToObjectTransformer(Student.class);
}

// PayloadTypeRouter Example
@ServiceActivator(inputChannel = "router.channel")
@Bean
public PayloadTypeRouter payloadRouter() {
PayloadTypeRouter router = new PayloadTypeRouter();
router.setChannelMapping(Student.class.getName(), "student.enrich.header.channel");
router.setChannelMapping(Address.class.getName(), "address.enrich.header.channel");
return router;
}

}