Add support for @EnableModule, @Input and @Output
* enable the component model based on @EnableModule with existing functionality * any field annotated with Input/Output will trigger the creation and injection of a channel * update examples and tests * update README
This commit is contained in:
committed by
Mark Fisher
parent
2fa5724cee
commit
23e4cbc7ac
@@ -18,29 +18,23 @@ package config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.streams.EnableChannelBinding;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
|
||||
import org.springframework.cloud.streams.annotation.EnableModule;
|
||||
import org.springframework.cloud.streams.annotation.Input;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
@Configuration
|
||||
@EnableChannelBinding
|
||||
@MessageEndpoint
|
||||
@EnableModule
|
||||
public class SinkModuleDefinition {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SinkModuleDefinition.class);
|
||||
|
||||
@Bean
|
||||
public MessageChannel input() {
|
||||
return new DirectChannel();
|
||||
}
|
||||
@Input
|
||||
public MessageChannel input;
|
||||
|
||||
@ServiceActivator(inputChannel="input")
|
||||
public void loggerSink(Object payload) {
|
||||
|
||||
@@ -20,31 +20,27 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.streams.EnableChannelBinding;
|
||||
import org.springframework.cloud.streams.annotation.EnableModule;
|
||||
import org.springframework.cloud.streams.annotation.Output;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.annotation.InboundChannelAdapter;
|
||||
import org.springframework.integration.annotation.Poller;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
@Configuration
|
||||
@EnableChannelBinding
|
||||
@EnableModule
|
||||
public class SourceModuleDefinition {
|
||||
|
||||
@Value("${format:YYYY/MM/dd hh:mm:ss}")
|
||||
private String format;
|
||||
|
||||
@Bean
|
||||
public MessageChannel output() {
|
||||
return new DirectChannel();
|
||||
}
|
||||
@Output
|
||||
public MessageChannel output;
|
||||
|
||||
@Bean
|
||||
@InboundChannelAdapter(value = "output", autoStartup = "false", poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
|
||||
|
||||
@@ -2,7 +2,6 @@ package demo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.streams.EnableChannelBinding;
|
||||
import org.springframework.cloud.streams.aggregate.AggregateBuilder;
|
||||
import org.springframework.cloud.streams.aggregate.AggregateConfigurer;
|
||||
|
||||
@@ -10,7 +9,6 @@ import config.SinkModuleDefinition;
|
||||
import config.SourceModuleDefinition;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableChannelBinding
|
||||
public class DoubleApplication implements AggregateConfigurer {
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user