Use @EnableModule(Channels.class) instead of field declarations

Standard channel interface types of Sink, Source, Processor
are provided, but user can create others with @Input and
@Output MessageChannel methods.

To get the declared channels in an app you can use the
@ModuleChannels qualifier to inject the interface, e.g.
@ModuleChannels(Cafe.class) injects the channels defined
in the Cafe.
This commit is contained in:
Dave Syer
2015-07-16 15:10:41 +01:00
committed by Mark Fisher
parent 460bb140f2
commit c09b292d79
22 changed files with 390 additions and 248 deletions

View File

@@ -18,20 +18,16 @@ package transform;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.stream.annotation.EnableModule;
import org.springframework.context.annotation.Bean;
import org.springframework.cloud.stream.annotation.Processor;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.SubscribableChannel;
/**
* @author Dave Syer
*
*/
@EnableModule
@EnableModule(Processor.class)
@ConfigurationProperties("module.logging")
public class LoggingTransformer {
@@ -50,17 +46,7 @@ public class LoggingTransformer {
this.name = name;
}
@Bean
public MessageChannel input() {
return new DirectChannel();
}
@Bean
public SubscribableChannel output() {
return new DirectChannel();
}
@ServiceActivator(inputChannel = "input", outputChannel = "output")
@ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object transform(Object payload) {
logger.info("Transformed by " + this.name + ": " + payload);
return payload;