From 970854fd6fb87e01bc310a2c4ee83d8bdce53467 Mon Sep 17 00:00:00 2001 From: Rob Moore Date: Fri, 24 Mar 2017 14:07:42 -0500 Subject: [PATCH] GH-2100: logging-adapter.adoc: Remove channel Fixes spring-projects/spring-integration#2100 Also add a sample how to configure logging channel adapter from Java DSL --- src/reference/asciidoc/logging-adapter.adoc | 40 ++++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/reference/asciidoc/logging-adapter.adoc b/src/reference/asciidoc/logging-adapter.adoc index e822932fc1..f3fd8664f2 100644 --- a/src/reference/asciidoc/logging-adapter.adoc +++ b/src/reference/asciidoc/logging-adapter.adoc @@ -58,11 +58,6 @@ public class LoggingJavaApplication { gateway.sendToLogger("foo"); } - @Bean - public MessageChannel logInputChannel() { - return new DirectChannel(); - } - @Bean @ServiceActivator(inputChannel = "logChannel") public LoggingHandler logging() { @@ -81,3 +76,38 @@ public class LoggingJavaApplication { } ---- + +==== Configuring with the Java DSL + +The following Spring Boot application provides an example of configuring the logging channel adapter using the Java DSL: + +[source, java] +---- +@SpringBootApplication +public class LoggingJavaApplication { + + public static void main(String[] args) { + ConfigurableApplicationContext context = + new SpringApplicationBuilder(LoggingJavaApplication.class) + .web(false) + .run(args); + MyGateway gateway = context.getBean(MyGateway.class); + gateway.sendToLogger("foo"); + } + + @Bean + public IntegrationFlow loggingFlow() { + return IntegrationFlows.from(MyGateway.class) + .log(LoggingHandler.Level.DEBUG, "TEST_LOGGER", + m -> m.getHeaders().getId() + ": " + m.getPayload()); + } + + @MessagingGateway + public interface MyGateway { + + void sendToLogger(String data); + + } + +} +---- \ No newline at end of file