From 841e05b266546d08ff882dbed1b035a32aedb5b3 Mon Sep 17 00:00:00 2001 From: Ilayaperumal Gopinathan Date: Mon, 6 Mar 2017 17:06:12 +0530 Subject: [PATCH] Add note on aggregate application doc Resolves #785 Fix review comments --- .../spring-cloud-stream-overview.adoc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/spring-cloud-stream-core-docs/src/main/asciidoc/spring-cloud-stream-overview.adoc b/spring-cloud-stream-core-docs/src/main/asciidoc/spring-cloud-stream-overview.adoc index b4fec3682..ff74e0a00 100644 --- a/spring-cloud-stream-core-docs/src/main/asciidoc/spring-cloud-stream-overview.adoc +++ b/spring-cloud-stream-core-docs/src/main/asciidoc/spring-cloud-stream-overview.adoc @@ -652,13 +652,24 @@ Depending on the nature of the starting and ending element, the sequence may hav Aggregation is performed using the `AggregateApplicationBuilder` utility class, as in the following example. Let's consider a project in which we have source, processor and a sink, which may be defined in the project, or may be contained in one of the project's dependencies. +[NOTE] +==== +Each component (source, sink or processor) in an aggregate application must be provided in a separate package if the configuration classes use `@SpringBootApplication`. +This is required to avoid cross-talk between applications, due to the classpath scanning performed by `@SpringBootApplication` on the configuration classes inside the same package. +In the example below, it can be seen that the Source, Processor and Sink application classes are grouped in separate packages. +A possible alternative is to provide the source, sink or processor configuration in a separate `@Configuration` class, avoid the use of `@SpringBootApplication`/`@ComponentScan` and use those for aggregation. +==== + + [source,java] ---- +package com.app.mysink; + @SpringBootApplication @EnableBinding(Sink.class) public class SinkApplication { - private static Logger logger = LoggerFactory.getLogger(SinkModuleDefinition.class); + private static Logger logger = LoggerFactory.getLogger(SinkApplication.class); @ServiceActivator(inputChannel=Sink.INPUT) public void loggerSink(Object payload) { @@ -669,6 +680,8 @@ public class SinkApplication { [source,java] ---- +package com.app.myprocessor; + @SpringBootApplication @EnableBinding(Processor.class) public class ProcessorApplication { @@ -682,6 +695,8 @@ public class ProcessorApplication { [source,java] ---- +package com.app.mysource; + @SpringBootApplication @EnableBinding(Source.class) public class SourceApplication { @@ -698,6 +713,8 @@ Each configuration can be used for running a separate component, but in this cas [source,java] ---- +package com.app; + @SpringBootApplication public class SampleAggregateApplication {