From 43c01f254500a213897aa0a16dda58f44332f45f Mon Sep 17 00:00:00 2001 From: Ilayaperumal Gopinathan Date: Tue, 16 Feb 2016 11:13:44 +0530 Subject: [PATCH] Remove spring-cloud-stream-samples - All the samples are moved into a separate repository This resolves #321 --- README.adoc | 215 ++++++++---------- pom.xml | 139 ++++++----- .../docker-compose.yml | 4 - spring-cloud-stream-samples/double/pom.xml | 59 ----- .../java/config/sink/SinkApplication.java | 26 --- .../config/sink/SinkModuleDefinition.java | 39 ---- .../java/config/source/SourceApplication.java | 26 --- .../config/source/SourceModuleDefinition.java | 45 ---- .../src/main/java/demo/DoubleApplication.java | 32 --- .../double/src/main/resources/application.yml | 1 - .../double/src/main/resources/sink.yml | 6 - .../double/src/main/resources/source.yml | 7 - .../java/demo/ModuleApplicationTests.java | 36 --- spring-cloud-stream-samples/extended/pom.xml | 70 ------ .../java/extended/ExtendedApplication.java | 46 ---- .../src/main/resources/application.yml | 6 - .../extended/src/main/resources/source.yml | 1 - .../java/demo/ModuleApplicationTests.java | 38 ---- .../multibinder-differentsystems/README.adoc | 12 - .../multibinder-differentsystems/pom.xml | 102 --------- .../java/multibinder/BridgeTransformer.java | 33 --- .../multibinder/MultibinderApplication.java | 29 --- .../src/main/resources/application.yml | 33 --- .../TwoKafkaBindersApplicationTest.java | 110 --------- .../multibinder/pom.xml | 79 ------- .../java/multibinder/BridgeTransformer.java | 33 --- .../multibinder/MultibinderApplication.java | 29 --- .../src/main/resources/application.yml | 12 - .../RabbitAndRedisBinderApplicationTests.java | 94 -------- spring-cloud-stream-samples/pom.xml | 63 ----- .../rxjava-processor/pom.xml | 62 ----- .../src/main/java/demo/RxJavaApplication.java | 33 --- .../src/main/java/demo/RxJavaTransformer.java | 51 ----- .../src/main/resources/application.yml | 8 - .../java/demo/ModuleApplicationTests.java | 36 --- spring-cloud-stream-samples/sink/README.md | 32 --- spring-cloud-stream-samples/sink/pom.xml | 58 ----- .../sink/src/main/java/demo/LogSink.java | 39 ---- .../src/main/java/demo/SinkApplication.java | 29 --- .../sink/src/main/resources/application.yml | 12 - .../java/demo/ModuleApplicationTests.java | 55 ----- spring-cloud-stream-samples/source/README.md | 38 ---- spring-cloud-stream-samples/source/pom.xml | 57 ----- .../source/src/main/java/demo/DateFormat.java | 93 -------- .../src/main/java/demo/SourceApplication.java | 29 --- .../source/src/main/java/demo/TimeSource.java | 50 ---- .../java/demo/TimeSourceOptionsMetadata.java | 103 --------- .../source/src/main/resources/application.yml | 24 -- .../java/demo/ModuleApplicationTests.java | 36 --- spring-cloud-stream-samples/transform/pom.xml | 59 ----- .../main/java/demo/LoggingTransformer.java | 55 ----- .../main/java/demo/TransformApplication.java | 29 --- .../src/main/resources/application.yml | 9 - .../java/demo/ModuleApplicationTests.java | 36 --- 54 files changed, 165 insertions(+), 2293 deletions(-) delete mode 100644 spring-cloud-stream-samples/docker-compose.yml delete mode 100644 spring-cloud-stream-samples/double/pom.xml delete mode 100644 spring-cloud-stream-samples/double/src/main/java/config/sink/SinkApplication.java delete mode 100644 spring-cloud-stream-samples/double/src/main/java/config/sink/SinkModuleDefinition.java delete mode 100644 spring-cloud-stream-samples/double/src/main/java/config/source/SourceApplication.java delete mode 100644 spring-cloud-stream-samples/double/src/main/java/config/source/SourceModuleDefinition.java delete mode 100644 spring-cloud-stream-samples/double/src/main/java/demo/DoubleApplication.java delete mode 100644 spring-cloud-stream-samples/double/src/main/resources/application.yml delete mode 100644 spring-cloud-stream-samples/double/src/main/resources/sink.yml delete mode 100644 spring-cloud-stream-samples/double/src/main/resources/source.yml delete mode 100644 spring-cloud-stream-samples/double/src/test/java/demo/ModuleApplicationTests.java delete mode 100644 spring-cloud-stream-samples/extended/pom.xml delete mode 100644 spring-cloud-stream-samples/extended/src/main/java/extended/ExtendedApplication.java delete mode 100644 spring-cloud-stream-samples/extended/src/main/resources/application.yml delete mode 100644 spring-cloud-stream-samples/extended/src/main/resources/source.yml delete mode 100644 spring-cloud-stream-samples/extended/src/test/java/demo/ModuleApplicationTests.java delete mode 100644 spring-cloud-stream-samples/multibinder-differentsystems/README.adoc delete mode 100644 spring-cloud-stream-samples/multibinder-differentsystems/pom.xml delete mode 100644 spring-cloud-stream-samples/multibinder-differentsystems/src/main/java/multibinder/BridgeTransformer.java delete mode 100644 spring-cloud-stream-samples/multibinder-differentsystems/src/main/java/multibinder/MultibinderApplication.java delete mode 100644 spring-cloud-stream-samples/multibinder-differentsystems/src/main/resources/application.yml delete mode 100644 spring-cloud-stream-samples/multibinder-differentsystems/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java delete mode 100644 spring-cloud-stream-samples/multibinder/pom.xml delete mode 100644 spring-cloud-stream-samples/multibinder/src/main/java/multibinder/BridgeTransformer.java delete mode 100644 spring-cloud-stream-samples/multibinder/src/main/java/multibinder/MultibinderApplication.java delete mode 100644 spring-cloud-stream-samples/multibinder/src/main/resources/application.yml delete mode 100644 spring-cloud-stream-samples/multibinder/src/test/java/multibinder/RabbitAndRedisBinderApplicationTests.java delete mode 100644 spring-cloud-stream-samples/pom.xml delete mode 100644 spring-cloud-stream-samples/rxjava-processor/pom.xml delete mode 100644 spring-cloud-stream-samples/rxjava-processor/src/main/java/demo/RxJavaApplication.java delete mode 100644 spring-cloud-stream-samples/rxjava-processor/src/main/java/demo/RxJavaTransformer.java delete mode 100644 spring-cloud-stream-samples/rxjava-processor/src/main/resources/application.yml delete mode 100644 spring-cloud-stream-samples/rxjava-processor/src/test/java/demo/ModuleApplicationTests.java delete mode 100644 spring-cloud-stream-samples/sink/README.md delete mode 100644 spring-cloud-stream-samples/sink/pom.xml delete mode 100644 spring-cloud-stream-samples/sink/src/main/java/demo/LogSink.java delete mode 100644 spring-cloud-stream-samples/sink/src/main/java/demo/SinkApplication.java delete mode 100644 spring-cloud-stream-samples/sink/src/main/resources/application.yml delete mode 100644 spring-cloud-stream-samples/sink/src/test/java/demo/ModuleApplicationTests.java delete mode 100644 spring-cloud-stream-samples/source/README.md delete mode 100644 spring-cloud-stream-samples/source/pom.xml delete mode 100644 spring-cloud-stream-samples/source/src/main/java/demo/DateFormat.java delete mode 100644 spring-cloud-stream-samples/source/src/main/java/demo/SourceApplication.java delete mode 100644 spring-cloud-stream-samples/source/src/main/java/demo/TimeSource.java delete mode 100644 spring-cloud-stream-samples/source/src/main/java/demo/TimeSourceOptionsMetadata.java delete mode 100644 spring-cloud-stream-samples/source/src/main/resources/application.yml delete mode 100644 spring-cloud-stream-samples/source/src/test/java/demo/ModuleApplicationTests.java delete mode 100644 spring-cloud-stream-samples/transform/pom.xml delete mode 100644 spring-cloud-stream-samples/transform/src/main/java/demo/LoggingTransformer.java delete mode 100644 spring-cloud-stream-samples/transform/src/main/java/demo/TransformApplication.java delete mode 100644 spring-cloud-stream-samples/transform/src/main/resources/application.yml delete mode 100644 spring-cloud-stream-samples/transform/src/test/java/demo/ModuleApplicationTests.java diff --git a/README.adoc b/README.adoc index 4ca103e45..156ed7cf6 100644 --- a/README.adoc +++ b/README.adoc @@ -1,119 +1,96 @@ -== Spring Cloud Stream image:https://build.spring.io/plugins/servlet/buildStatusImage/SCS-SMJLE[Build Status, link=https://build.spring.io/browse/SCS-SMJLE] image:https://badge.waffle.io/spring-cloud/spring-cloud-stream.svg?label=ready&title=Ready[Stories Ready, link=http://waffle.io/spring-cloud/spring-cloud-stream] image:https://badge.waffle.io/spring-cloud/spring-cloud-stream.svg?label=In%20Progress&title=In%20Progress[Stores In Progress, link=http://waffle.io/spring-cloud/spring-cloud-stream] - -This project allows a user to develop and run messaging microservices using Spring Integration and run them locally, or in the cloud, or even on Spring XD. Just add `@EnableBinding` and run your app as a Spring Boot app (single application context). You just need to connect to the physical broker for the bindings, which is automatic if the relevant binder implementation is available on the classpath. The sample uses Redis. - -Here's a sample source module (output channel only): - -[source,java] ----- -@SpringBootApplication -public class ModuleApplication { - - public static void main(String[] args) { - SpringApplication.run(ModuleApplication.class, args); - } - -} - -@EnableBinding(Source.class) -public class TimerSource { - - @Value("${format}") - private String format; - - @Bean - @InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1")) - public MessageSource timerMessageSource() { - return () -> new GenericMessage<>(new SimpleDateFormat(format).format(new Date())); - } - -} ----- - -`@EnableBinding` is parameterized by an interface (in this case `Source`) which declares input and output channels. `Source`, `Sink` and `Processor` are provided off the shelf, but you can define others. Here's the definition of `Source`: - -[source,java] ----- -public interface Source { - @Output("output") - MessageChannel output(); -} ----- - -The `@Output` annotation is used to identify output channels (messages leaving the module) and `@Input` is used to identify input channels (messages entering the module). It is optionally parameterized by a channel name - if the name is not provided the method name is used instead. An implementation of the interface is created for you and can be used in the application context by autowiring it, e.g. into a test case: - -[source,java] ----- -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = ModuleApplication.class) -@WebAppConfiguration -@DirtiesContext -public class ModuleApplicationTests { - - @Autowired - private Source source; - - @Test - public void contextLoads() { - assertNotNull(this.source.output()); - } - -} ----- - -NOTE: In this case there is only one `Source` in the application context so there is no need to qualify it when it is autowired. If there is ambiguity, e.g. if you are composing one module from some others, you can use `@Bindings` qualifier to inject a specific channel set. The `@Bindings` qualifier takes a parameter which is the class that carries the `@EnableBinding` annotation (in this case the `TimerSource`). - -== Multiple Input or Output Channels - -A module can have multiple input or output channels all defined either as `@Input` and `@Output` methods in an interface (preferrable) or as bean definitions. Instead of just one channel named "input" or "output" you can add multiple `MessageChannel` methods annotated `@Input` or `@Output` and the names are converted to external channel names on the broker. The external channel names can be specified as properties that consist of the channel names prefixed with `spring.cloud.stream.bindings` (e.g. `spring.cloud.stream.bindings.input.destination` or `spring.cloud.stream.bindings.output.destination`). External channel names can have a channel type as a colon-separated prefix, and the semantics of the external bus channel changes accordingly. For example, you can have two `MessageChannels` called "output" and "foo" in a module with `spring.cloud.stream.bindings.output.destination=bar` and `spring.cloud.stream.bindings.foo.destination=topic:foo`, and the result is 2 external channels called "bar" and "topic:foo". - -== Samples - -There are several samples, all running on the redis transport (so you need redis running locally to test them). - - -NOTE: The main set of samples are "vanilla" in the sense that they are not deployable as XD modules by the current generation (1.x) of XD. You can still interact with an XD system using the appropriate naming convention for input and output channel names (`.` format). - -* `source` is a Java config version of the classic "timer" module from Spring XD. It has a "fixedDelay" option (in milliseconds) for the period between emitting messages. - -* `sink` is a Java config version of the classic "log" module from Spring XD. It has no options (but some could easily be added), and just logs incoming messages at INFO level. - -* `transform` is a simple pass through logging transformer (just logs the incoming message and passes it on). - -* `double` is a combination of 2 modules defined locally (a source and a sink, so the whole app is self contained). - -* `extended` is a multi-module mashup of `source | transform | transform | sink`, where the modules are defined in the other samples and referred to in this app just as dependencies. - -* `multibinder` is a sample application that shows how an application could use multiple binders. In this case, the processor's input/output channels connect to different brokers using their own binder configurations. - -* `multibinder-differentsystems` shows how an application could use same binder implementation but different configurations for its channels. In this case, a processor's input/output channels connect to same binder implementation but with two separate broker configurations. - -If you run the source and the sink and point them at the same redis instance (e.g. do nothing to get the one on localhost, or the one they are both bound to as a service on Cloud Foundry) then they will form a "stream" and start talking to each other. All the samples have friendly JMX and Actuator endpoints for inspecting what is going on in the system. - -== Module or App - -Code using this library can be deployed as a standalone app or as an XD module. In standalone mode your app will run happily as a service or in any PaaS (Cloud Foundry, Lattice, Heroku, Azure, etc.). Depending on whether your main aim is to develop an XD module and you just want to test it locally using the standalone mode, or if the ultimate goal is a standalone app, there are some things that you might do differently. - -=== Fat JAR - -You can run in standalone mode from your IDE for testing. To run in production you can create an executable (or "fat") JAR using the standard Spring Boot tooling. -// To be confirmed... -// the executable JAR has a load of stuff in it that isn't needed if it's going to be deployed as an XD module. In that case you are better off with the normal JAR packaging provided by Maven or Gradle. - -== Making Standalone Modules Talk to Each Other - -The `[input,output]ChannelName` are used to create physical endpoints in the external broker (e.g. `queue.` in Redis). - -For an XD module the channel names are `.` and a source (output only) has `index=0` (the default) and downstream modules have the same group but incremented index, with a sink module (input only) having the highest index. To listen to the output from a running XD module, just use the same "group" name and an index 1 larger than the app before it in the chain. - -> Note: since the same naming conventions are used in XD, you can steal messages from or send messages to an existing XD stream by copying the stream name (to `spring.cloud.stream..group`) and knowing the index of the XD module you want to interact with. - -=== Contributing - -// TODO point to ref doc section - -We love contributions. Follow this https://github.com/spring-cloud/spring-cloud-commons#contributing[link] for more information on how to contribute. - -// Building -// -// TODO point to ref doc section +== Spring Cloud Stream image:https://build.spring.io/plugins/servlet/buildStatusImage/SCS-SMJLE[Build Status, link=https://build.spring.io/browse/SCS-SMJLE] image:https://badge.waffle.io/spring-cloud/spring-cloud-stream.svg?label=ready&title=Ready[Stories Ready, link=http://waffle.io/spring-cloud/spring-cloud-stream] image:https://badge.waffle.io/spring-cloud/spring-cloud-stream.svg?label=In%20Progress&title=In%20Progress[Stores In Progress, link=http://waffle.io/spring-cloud/spring-cloud-stream] + +This project allows a user to develop and run messaging microservices using Spring Integration and run them locally, or in the cloud, or even on Spring XD. Just add `@EnableBinding` and run your app as a Spring Boot app (single application context). You just need to connect to the physical broker for the bindings, which is automatic if the relevant binder implementation is available on the classpath. The sample uses Redis. + +Here's a sample source module (output channel only): + +[source,java] +---- +@SpringBootApplication +public class ModuleApplication { + + public static void main(String[] args) { + SpringApplication.run(ModuleApplication.class, args); + } + +} + +@EnableBinding(Source.class) +public class TimerSource { + + @Value("${format}") + private String format; + + @Bean + @InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1")) + public MessageSource timerMessageSource() { + return () -> new GenericMessage<>(new SimpleDateFormat(format).format(new Date())); + } + +} +---- + +`@EnableBinding` is parameterized by an interface (in this case `Source`) which declares input and output channels. `Source`, `Sink` and `Processor` are provided off the shelf, but you can define others. Here's the definition of `Source`: + +[source,java] +---- +public interface Source { + @Output("output") + MessageChannel output(); +} +---- + +The `@Output` annotation is used to identify output channels (messages leaving the module) and `@Input` is used to identify input channels (messages entering the module). It is optionally parameterized by a channel name - if the name is not provided the method name is used instead. An implementation of the interface is created for you and can be used in the application context by autowiring it, e.g. into a test case: + +[source,java] +---- +@RunWith(SpringJUnit4ClassRunner.class) +@SpringApplicationConfiguration(classes = ModuleApplication.class) +@WebAppConfiguration +@DirtiesContext +public class ModuleApplicationTests { + + @Autowired + private Source source; + + @Test + public void contextLoads() { + assertNotNull(this.source.output()); + } + +} +---- + +NOTE: In this case there is only one `Source` in the application context so there is no need to qualify it when it is autowired. If there is ambiguity, e.g. if you are composing one module from some others, you can use `@Bindings` qualifier to inject a specific channel set. The `@Bindings` qualifier takes a parameter which is the class that carries the `@EnableBinding` annotation (in this case the `TimerSource`). + +== Multiple Input or Output Channels + +A module can have multiple input or output channels all defined either as `@Input` and `@Output` methods in an interface (preferrable) or as bean definitions. Instead of just one channel named "input" or "output" you can add multiple `MessageChannel` methods annotated `@Input` or `@Output` and the names are converted to external channel names on the broker. The external channel names can be specified as properties that consist of the channel names prefixed with `spring.cloud.stream.bindings` (e.g. `spring.cloud.stream.bindings.input.destination` or `spring.cloud.stream.bindings.output.destination`). External channel names can have a channel type as a colon-separated prefix, and the semantics of the external bus channel changes accordingly. For example, you can have two `MessageChannels` called "output" and "foo" in a module with `spring.cloud.stream.bindings.output.destination=bar` and `spring.cloud.stream.bindings.foo.destination=topic:foo`, and the result is 2 external channels called "bar" and "topic:foo". + +== Module or App + +Code using this library can be deployed as a standalone app or as an XD module. In standalone mode your app will run happily as a service or in any PaaS (Cloud Foundry, Lattice, Heroku, Azure, etc.). Depending on whether your main aim is to develop an XD module and you just want to test it locally using the standalone mode, or if the ultimate goal is a standalone app, there are some things that you might do differently. + +=== Fat JAR + +You can run in standalone mode from your IDE for testing. To run in production you can create an executable (or "fat") JAR using the standard Spring Boot tooling. +// To be confirmed... +// the executable JAR has a load of stuff in it that isn't needed if it's going to be deployed as an XD module. In that case you are better off with the normal JAR packaging provided by Maven or Gradle. + +== Making Standalone Modules Talk to Each Other + +The `[input,output]ChannelName` are used to create physical endpoints in the external broker (e.g. `queue.` in Redis). + +For an XD module the channel names are `.` and a source (output only) has `index=0` (the default) and downstream modules have the same group but incremented index, with a sink module (input only) having the highest index. To listen to the output from a running XD module, just use the same "group" name and an index 1 larger than the app before it in the chain. + +> Note: since the same naming conventions are used in XD, you can steal messages from or send messages to an existing XD stream by copying the stream name (to `spring.cloud.stream..group`) and knowing the index of the XD module you want to interact with. + +=== Contributing + +// TODO point to ref doc section + +We love contributions. Follow this https://github.com/spring-cloud/spring-cloud-commons#contributing[link] for more information on how to contribute. + +// Building +// +// TODO point to ref doc section diff --git a/pom.xml b/pom.xml index d9f344125..288dd7a2d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,70 +1,69 @@ - - - 4.0.0 - org.springframework.cloud - spring-cloud-stream-parent - 1.0.0.BUILD-SNAPSHOT - pom - - org.springframework.cloud - spring-cloud-build - 1.1.0.BUILD-SNAPSHOT - - - - https://github.com/spring-cloud/spring-cloud-stream - scm:git:git://github.com/spring-cloud/spring-cloud-stream.git - scm:git:ssh://git@github.com/spring-cloud/spring-cloud-stream.git - HEAD - - - 1.7 - - - - - org.springframework.cloud - spring-cloud-stream-dependencies - 1.0.0.BUILD-SNAPSHOT - pom - import - - - - - spring-cloud-stream-dependencies - spring-cloud-stream - spring-cloud-stream-binders - spring-cloud-stream-codec - spring-cloud-stream-tuple - spring-cloud-stream-starters - spring-cloud-stream-rxjava - spring-cloud-stream-samples - spring-cloud-stream-module-launcher - spring-cloud-stream-test-support - spring-cloud-stream-test-support-internal - spring-cloud-stream-integration-tests - spring-cloud-stream-configuration-metadata - spring-cloud-stream-docs - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - true - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - - - + + + 4.0.0 + org.springframework.cloud + spring-cloud-stream-parent + 1.0.0.BUILD-SNAPSHOT + pom + + org.springframework.cloud + spring-cloud-build + 1.1.0.BUILD-SNAPSHOT + + + + https://github.com/spring-cloud/spring-cloud-stream + scm:git:git://github.com/spring-cloud/spring-cloud-stream.git + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-stream.git + HEAD + + + 1.7 + + + + + org.springframework.cloud + spring-cloud-stream-dependencies + 1.0.0.BUILD-SNAPSHOT + pom + import + + + + + spring-cloud-stream-dependencies + spring-cloud-stream + spring-cloud-stream-binders + spring-cloud-stream-codec + spring-cloud-stream-tuple + spring-cloud-stream-starters + spring-cloud-stream-rxjava + spring-cloud-stream-module-launcher + spring-cloud-stream-test-support + spring-cloud-stream-test-support-internal + spring-cloud-stream-integration-tests + spring-cloud-stream-configuration-metadata + spring-cloud-stream-docs + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + true + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + + diff --git a/spring-cloud-stream-samples/docker-compose.yml b/spring-cloud-stream-samples/docker-compose.yml deleted file mode 100644 index e5a62d0ef..000000000 --- a/spring-cloud-stream-samples/docker-compose.yml +++ /dev/null @@ -1,4 +0,0 @@ -redis: - image: redis - ports: - - "6379:6379" diff --git a/spring-cloud-stream-samples/double/pom.xml b/spring-cloud-stream-samples/double/pom.xml deleted file mode 100644 index 9a658f268..000000000 --- a/spring-cloud-stream-samples/double/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - 4.0.0 - - spring-cloud-stream-sample-double - jar - - spring-cloud-stream-sample-double - Demo project for Aggregate Builder - - - org.springframework.cloud - spring-cloud-stream-samples - 1.0.0.BUILD-SNAPSHOT - - - - demo.DoubleApplication - - - - - org.springframework.cloud - spring-cloud-stream - - - org.springframework.cloud - spring-cloud-stream-binder-redis - - - org.springframework.boot - spring-boot-starter-redis - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - exec - - - - - - diff --git a/spring-cloud-stream-samples/double/src/main/java/config/sink/SinkApplication.java b/spring-cloud-stream-samples/double/src/main/java/config/sink/SinkApplication.java deleted file mode 100644 index e093d1ff9..000000000 --- a/spring-cloud-stream-samples/double/src/main/java/config/sink/SinkApplication.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config.sink; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * @author Marius Bogoevici - */ -@SpringBootApplication -public class SinkApplication { -} diff --git a/spring-cloud-stream-samples/double/src/main/java/config/sink/SinkModuleDefinition.java b/spring-cloud-stream-samples/double/src/main/java/config/sink/SinkModuleDefinition.java deleted file mode 100644 index 995ff6293..000000000 --- a/spring-cloud-stream-samples/double/src/main/java/config/sink/SinkModuleDefinition.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config.sink; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.messaging.Sink; -import org.springframework.integration.annotation.ServiceActivator; - -/** - * @author Dave Syer - * @author Marius Bogoevici - */ -@EnableBinding(Sink.class) -public class SinkModuleDefinition { - - private static Logger logger = LoggerFactory.getLogger(SinkModuleDefinition.class); - - @ServiceActivator(inputChannel=Sink.INPUT) - public void loggerSink(Object payload) { - logger.info("Received: " + payload); - } - -} diff --git a/spring-cloud-stream-samples/double/src/main/java/config/source/SourceApplication.java b/spring-cloud-stream-samples/double/src/main/java/config/source/SourceApplication.java deleted file mode 100644 index f1d907786..000000000 --- a/spring-cloud-stream-samples/double/src/main/java/config/source/SourceApplication.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config.source; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * @author Marius Bogoevici - */ -@SpringBootApplication -public class SourceApplication { -} diff --git a/spring-cloud-stream-samples/double/src/main/java/config/source/SourceModuleDefinition.java b/spring-cloud-stream-samples/double/src/main/java/config/source/SourceModuleDefinition.java deleted file mode 100644 index 215688750..000000000 --- a/spring-cloud-stream-samples/double/src/main/java/config/source/SourceModuleDefinition.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config.source; - -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.messaging.Source; -import org.springframework.context.annotation.Bean; -import org.springframework.integration.annotation.InboundChannelAdapter; -import org.springframework.integration.annotation.Poller; -import org.springframework.integration.core.MessageSource; -import org.springframework.messaging.support.GenericMessage; - -/** - * @author Dave Syer - * @author Marius Bogoevici - */ -@EnableBinding(Source.class) -public class SourceModuleDefinition { - - private String format = "yyyy-MM-dd HH:mm:ss"; - - @Bean - @InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1")) - public MessageSource timerMessageSource() { - return () -> new GenericMessage<>(new SimpleDateFormat(this.format).format(new Date())); - } - -} diff --git a/spring-cloud-stream-samples/double/src/main/java/demo/DoubleApplication.java b/spring-cloud-stream-samples/double/src/main/java/demo/DoubleApplication.java deleted file mode 100644 index 3ebe00bd1..000000000 --- a/spring-cloud-stream-samples/double/src/main/java/demo/DoubleApplication.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.stream.aggregate.AggregateApplication; - -import config.sink.SinkApplication; -import config.source.SourceApplication; - -@SpringBootApplication -public class DoubleApplication { - - public static void main(String[] args) { - AggregateApplication.run(SourceApplication.class, SinkApplication.class); - } - -} diff --git a/spring-cloud-stream-samples/double/src/main/resources/application.yml b/spring-cloud-stream-samples/double/src/main/resources/application.yml deleted file mode 100644 index d84e8d13d..000000000 --- a/spring-cloud-stream-samples/double/src/main/resources/application.yml +++ /dev/null @@ -1 +0,0 @@ -fixedDelay: 1000 diff --git a/spring-cloud-stream-samples/double/src/main/resources/sink.yml b/spring-cloud-stream-samples/double/src/main/resources/sink.yml deleted file mode 100644 index a0f178ec6..000000000 --- a/spring-cloud-stream-samples/double/src/main/resources/sink.yml +++ /dev/null @@ -1,6 +0,0 @@ -spring: - cloud: - stream: - bindings: - input: testtock - \ No newline at end of file diff --git a/spring-cloud-stream-samples/double/src/main/resources/source.yml b/spring-cloud-stream-samples/double/src/main/resources/source.yml deleted file mode 100644 index ac31a8981..000000000 --- a/spring-cloud-stream-samples/double/src/main/resources/source.yml +++ /dev/null @@ -1,7 +0,0 @@ -fixedDelay: 5000 -spring: - cloud: - stream: - bindings: - output: testtock - \ No newline at end of file diff --git a/spring-cloud-stream-samples/double/src/test/java/demo/ModuleApplicationTests.java b/spring-cloud-stream-samples/double/src/test/java/demo/ModuleApplicationTests.java deleted file mode 100644 index 361e02811..000000000 --- a/spring-cloud-stream-samples/double/src/test/java/demo/ModuleApplicationTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = DoubleApplication.class) -@WebAppConfiguration -@DirtiesContext -public class ModuleApplicationTests { - - @Test - public void contextLoads() { - } - -} diff --git a/spring-cloud-stream-samples/extended/pom.xml b/spring-cloud-stream-samples/extended/pom.xml deleted file mode 100644 index cc10812ff..000000000 --- a/spring-cloud-stream-samples/extended/pom.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - 4.0.0 - - spring-cloud-stream-sample-extended - jar - spring-cloud-stream-sample-extended - Demo project for extended module using aggregate builder - - - org.springframework.cloud - spring-cloud-stream-samples - 1.0.0.BUILD-SNAPSHOT - - - - extended.ExtendedApplication - - - - - org.springframework.cloud - spring-cloud-stream - - - org.springframework.cloud - spring-cloud-stream-sample-source - - - org.springframework.cloud - spring-cloud-stream-sample-transform - - - org.springframework.cloud - spring-cloud-stream-sample-sink - - - org.springframework.cloud - spring-cloud-stream-binder-redis - - - org.springframework.boot - spring-boot-starter-redis - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - exec - - - - - - diff --git a/spring-cloud-stream-samples/extended/src/main/java/extended/ExtendedApplication.java b/spring-cloud-stream-samples/extended/src/main/java/extended/ExtendedApplication.java deleted file mode 100644 index b4c5e3d2f..000000000 --- a/spring-cloud-stream-samples/extended/src/main/java/extended/ExtendedApplication.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package extended; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.stream.aggregate.AggregateBuilder; -import org.springframework.cloud.stream.aggregate.AggregateConfigurer; - -import demo.LogSink; -import demo.LoggingTransformer; -import demo.TimeSource; - -@SpringBootApplication -public class ExtendedApplication implements AggregateConfigurer { - - @Override - public void configure(AggregateBuilder builder) { - // @formatter:off - builder - .from(TimeSource.class).as("source") - .via(LoggingTransformer.class) - .via(LoggingTransformer.class).profiles("other") - .to(LogSink.class); - // @formatter:on - } - - public static void main(String[] args) { - SpringApplication.run(ExtendedApplication.class, args); - } - -} diff --git a/spring-cloud-stream-samples/extended/src/main/resources/application.yml b/spring-cloud-stream-samples/extended/src/main/resources/application.yml deleted file mode 100644 index a70e9bc69..000000000 --- a/spring-cloud-stream-samples/extended/src/main/resources/application.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -spring: - profiles: other -module: - logging: - name: other \ No newline at end of file diff --git a/spring-cloud-stream-samples/extended/src/main/resources/source.yml b/spring-cloud-stream-samples/extended/src/main/resources/source.yml deleted file mode 100644 index daf5166e5..000000000 --- a/spring-cloud-stream-samples/extended/src/main/resources/source.yml +++ /dev/null @@ -1 +0,0 @@ -fixedDelay: 5000 diff --git a/spring-cloud-stream-samples/extended/src/test/java/demo/ModuleApplicationTests.java b/spring-cloud-stream-samples/extended/src/test/java/demo/ModuleApplicationTests.java deleted file mode 100644 index 2683a46a5..000000000 --- a/spring-cloud-stream-samples/extended/src/test/java/demo/ModuleApplicationTests.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import extended.ExtendedApplication; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = ExtendedApplication.class) -@WebAppConfiguration -@DirtiesContext -public class ModuleApplicationTests { - - @Test - public void contextLoads() { - } - -} diff --git a/spring-cloud-stream-samples/multibinder-differentsystems/README.adoc b/spring-cloud-stream-samples/multibinder-differentsystems/README.adoc deleted file mode 100644 index f24102665..000000000 --- a/spring-cloud-stream-samples/multibinder-differentsystems/README.adoc +++ /dev/null @@ -1,12 +0,0 @@ -== Spring Cloud Stream Multibinder Application with Different Systems - -This example shows how to run a Spring Cloud Stream application with the same binder type configured for two separate Kafka clusters. - -To run the example, command line parameters for the Zookeeper ensembles and Kafka clusters must be provided, as in the following example: - -```` -java -jar spring-cloud-stream-samples/multibinder-differentsystems/target/spring-cloud-stream-sample-multibinder-differentsystems-1.0.0.BUILD-SNAPSHOT-exec.jar --kafkaBroker1=localhost:9092 --zk1=localhost:2181 --kafkaBroker2=localhost:9093 --zk2=localhost:2182 -```` - -This assumes that two Kafka clusters and Zookeeper ensembles are running locally. Alternatively, the default values of `localhost:9092` and `localhost:2181` can be provided for both clusters. - diff --git a/spring-cloud-stream-samples/multibinder-differentsystems/pom.xml b/spring-cloud-stream-samples/multibinder-differentsystems/pom.xml deleted file mode 100644 index 35addd9c3..000000000 --- a/spring-cloud-stream-samples/multibinder-differentsystems/pom.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - 4.0.0 - - spring-cloud-stream-sample-multibinder-differentsystems - jar - spring-cloud-stream-sample-multibinder-differentsystems - - Demo project for multiple binders of the same type (Kafka), connecting to different systems (broker groups) - - - - org.springframework.cloud - spring-cloud-stream-samples - 1.0.0.BUILD-SNAPSHOT - - - - multibinder.MultibinderApplication - - - - - org.springframework.cloud - spring-cloud-stream - - - org.springframework.cloud - spring-cloud-stream-sample-source - - - org.springframework.cloud - spring-cloud-stream-sample-transform - - - org.springframework.cloud - spring-cloud-stream-sample-sink - - - org.springframework.cloud - spring-cloud-stream-binder-redis - - - org.springframework.cloud - spring-cloud-stream-binder-kafka - - - org.springframework.cloud - spring-cloud-stream-test-support-internal - test - - - org.apache.kafka - kafka_2.10 - test - 0.8.2.1 - test - - - org.slf4j - slf4j-log4j12 - - - - - org.apache.curator - curator-test - 2.6.0 - test - - - org.slf4j - slf4j-log4j12 - - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - exec - - - - - - diff --git a/spring-cloud-stream-samples/multibinder-differentsystems/src/main/java/multibinder/BridgeTransformer.java b/spring-cloud-stream-samples/multibinder-differentsystems/src/main/java/multibinder/BridgeTransformer.java deleted file mode 100644 index d68720ffe..000000000 --- a/spring-cloud-stream-samples/multibinder-differentsystems/src/main/java/multibinder/BridgeTransformer.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package multibinder; - -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.messaging.Processor; -import org.springframework.integration.annotation.ServiceActivator; - -/** - * @author Marius Bogoevici - */ -@EnableBinding(Processor.class) -public class BridgeTransformer { - - @ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT) - public Object transform(Object payload) { - return payload; - } -} diff --git a/spring-cloud-stream-samples/multibinder-differentsystems/src/main/java/multibinder/MultibinderApplication.java b/spring-cloud-stream-samples/multibinder-differentsystems/src/main/java/multibinder/MultibinderApplication.java deleted file mode 100644 index 7aba5f67b..000000000 --- a/spring-cloud-stream-samples/multibinder-differentsystems/src/main/java/multibinder/MultibinderApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package multibinder; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class MultibinderApplication { - - public static void main(String[] args) { - SpringApplication.run(MultibinderApplication.class, args); - } - -} diff --git a/spring-cloud-stream-samples/multibinder-differentsystems/src/main/resources/application.yml b/spring-cloud-stream-samples/multibinder-differentsystems/src/main/resources/application.yml deleted file mode 100644 index ca88423b9..000000000 --- a/spring-cloud-stream-samples/multibinder-differentsystems/src/main/resources/application.yml +++ /dev/null @@ -1,33 +0,0 @@ -server: - port: 8082 -spring: - cloud: - stream: - bindings: - input: - destination: dataIn - binder: kafka1 - output: - destination: dataOut - binder: kafka2 - binders: - kafka1: - type: kafka - environment: - spring: - cloud: - stream: - binder: - kafka: - brokers: ${kafkaBroker1} - zkNodes: ${zk1} - kafka2: - type: kafka - environment: - spring: - cloud: - stream: - binder: - kafka: - brokers: ${kafkaBroker2} - zkNodes: ${zk2} diff --git a/spring-cloud-stream-samples/multibinder-differentsystems/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java b/spring-cloud-stream-samples/multibinder-differentsystems/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java deleted file mode 100644 index 6b16ce0e9..000000000 --- a/spring-cloud-stream-samples/multibinder-differentsystems/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2015-2016 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package multibinder; - -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.hasSize; - -import java.util.List; -import java.util.UUID; - -import org.hamcrest.CoreMatchers; -import org.hamcrest.Matchers; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.DirectFieldAccessor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.cloud.stream.binder.BinderFactory; -import org.springframework.cloud.stream.binder.kafka.KafkaMessageChannelBinder; -import org.springframework.cloud.stream.test.junit.kafka.KafkaTestSupport; -import org.springframework.cloud.stream.test.junit.redis.RedisTestSupport; -import org.springframework.integration.channel.DirectChannel; -import org.springframework.integration.channel.QueueChannel; -import org.springframework.integration.kafka.core.BrokerAddress; -import org.springframework.integration.kafka.core.Configuration; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.support.MessageBuilder; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = MultibinderApplication.class) -@WebAppConfiguration -@DirtiesContext -public class TwoKafkaBindersApplicationTest { - - @ClassRule - public static KafkaTestSupport kafkaTestSupport1 = new KafkaTestSupport(true); - - @ClassRule - public static KafkaTestSupport kafkaTestSupport2 = new KafkaTestSupport(true); - - @ClassRule - public static RedisTestSupport redisTestSupport = new RedisTestSupport(); - - @BeforeClass - public static void setupEnvironment() { - System.setProperty("kafkaBroker1", kafkaTestSupport1.getBrokerAddress()); - System.setProperty("zk1", kafkaTestSupport1.getZkConnectString()); - System.setProperty("kafkaBroker2", kafkaTestSupport2.getBrokerAddress()); - System.setProperty("zk2", kafkaTestSupport2.getZkConnectString()); - } - - @Autowired - private BinderFactory binderFactory; - - @Test - public void contextLoads() { - KafkaMessageChannelBinder kafka1 = (KafkaMessageChannelBinder) binderFactory.getBinder("kafka1"); - DirectFieldAccessor directFieldAccessor = new DirectFieldAccessor(kafka1.getConnectionFactory()); - Configuration configuration = (Configuration) directFieldAccessor.getPropertyValue("configuration"); - List brokerAddresses = configuration.getBrokerAddresses(); - Assert.assertThat(brokerAddresses, hasSize(1)); - Assert.assertThat(brokerAddresses, contains(BrokerAddress.fromAddress(kafkaTestSupport1.getBrokerAddress()))); - KafkaMessageChannelBinder kafka2 = (KafkaMessageChannelBinder) binderFactory.getBinder("kafka2"); - DirectFieldAccessor directFieldAccessor2 = new DirectFieldAccessor(kafka2.getConnectionFactory()); - Configuration configuration2 = (Configuration) directFieldAccessor2.getPropertyValue("configuration"); - List brokerAddresses2 = configuration2.getBrokerAddresses(); - Assert.assertThat(brokerAddresses2, hasSize(1)); - Assert.assertThat(brokerAddresses2, contains(BrokerAddress.fromAddress(kafkaTestSupport2.getBrokerAddress()))); - } - - @Test - public void messagingWorks() { - DirectChannel dataProducer = new DirectChannel(); - binderFactory.getBinder("kafka1").bindProducer("dataIn", dataProducer, null); - - QueueChannel dataConsumer = new QueueChannel(); - binderFactory.getBinder("kafka2").bindConsumer("dataOut", UUID.randomUUID().toString(), - dataConsumer, null); - - String testPayload = "testFoo" + UUID.randomUUID().toString(); - dataProducer.send(MessageBuilder.withPayload(testPayload).build()); - - Message receive = dataConsumer.receive(2000); - Assert.assertThat(receive, Matchers.notNullValue()); - Assert.assertThat(receive.getPayload(), CoreMatchers.equalTo(testPayload)); - } - -} diff --git a/spring-cloud-stream-samples/multibinder/pom.xml b/spring-cloud-stream-samples/multibinder/pom.xml deleted file mode 100644 index 36ebe1d7f..000000000 --- a/spring-cloud-stream-samples/multibinder/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - 4.0.0 - - spring-cloud-stream-sample-multibinder - jar - spring-cloud-stream-sample-multibinder - Demo project for multiple binders of different types (Redis and Rabbit) - - - org.springframework.cloud - spring-cloud-stream-samples - 1.0.0.BUILD-SNAPSHOT - - - - multibinder.MultibinderApplication - - - - - org.springframework.cloud - spring-cloud-stream - - - org.springframework.cloud - spring-cloud-stream-sample-source - - - org.springframework.cloud - spring-cloud-stream-sample-transform - - - org.springframework.cloud - spring-cloud-stream-sample-sink - - - org.springframework.cloud - spring-cloud-stream-binder-redis - - - org.springframework.cloud - spring-cloud-stream-binder-rabbit - - - org.springframework.cloud - spring-cloud-stream-test-support-internal - test - - - org.springframework.boot - spring-boot-starter-redis - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - exec - - - - - - diff --git a/spring-cloud-stream-samples/multibinder/src/main/java/multibinder/BridgeTransformer.java b/spring-cloud-stream-samples/multibinder/src/main/java/multibinder/BridgeTransformer.java deleted file mode 100644 index d68720ffe..000000000 --- a/spring-cloud-stream-samples/multibinder/src/main/java/multibinder/BridgeTransformer.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package multibinder; - -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.messaging.Processor; -import org.springframework.integration.annotation.ServiceActivator; - -/** - * @author Marius Bogoevici - */ -@EnableBinding(Processor.class) -public class BridgeTransformer { - - @ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT) - public Object transform(Object payload) { - return payload; - } -} diff --git a/spring-cloud-stream-samples/multibinder/src/main/java/multibinder/MultibinderApplication.java b/spring-cloud-stream-samples/multibinder/src/main/java/multibinder/MultibinderApplication.java deleted file mode 100644 index 7aba5f67b..000000000 --- a/spring-cloud-stream-samples/multibinder/src/main/java/multibinder/MultibinderApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package multibinder; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class MultibinderApplication { - - public static void main(String[] args) { - SpringApplication.run(MultibinderApplication.class, args); - } - -} diff --git a/spring-cloud-stream-samples/multibinder/src/main/resources/application.yml b/spring-cloud-stream-samples/multibinder/src/main/resources/application.yml deleted file mode 100644 index 9c3cb2180..000000000 --- a/spring-cloud-stream-samples/multibinder/src/main/resources/application.yml +++ /dev/null @@ -1,12 +0,0 @@ -server: - port: 8082 -spring: - cloud: - stream: - bindings: - input: - destination: dataIn - binder: redis - output: - destination: dataOut - binder: rabbit diff --git a/spring-cloud-stream-samples/multibinder/src/test/java/multibinder/RabbitAndRedisBinderApplicationTests.java b/spring-cloud-stream-samples/multibinder/src/test/java/multibinder/RabbitAndRedisBinderApplicationTests.java deleted file mode 100644 index 93b70f19d..000000000 --- a/spring-cloud-stream-samples/multibinder/src/test/java/multibinder/RabbitAndRedisBinderApplicationTests.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2015-2016 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package multibinder; - -import java.util.UUID; - -import org.hamcrest.CoreMatchers; -import org.hamcrest.Matchers; -import org.junit.After; -import org.junit.Assert; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.amqp.rabbit.core.RabbitAdmin; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.cloud.stream.binder.BinderFactory; -import org.springframework.cloud.stream.test.junit.rabbit.RabbitTestSupport; -import org.springframework.cloud.stream.test.junit.redis.RedisTestSupport; -import org.springframework.integration.channel.DirectChannel; -import org.springframework.integration.channel.QueueChannel; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.support.MessageBuilder; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; - -/** - * @author Marius Bogoevici - * @author Gary Russell - */ -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = MultibinderApplication.class) -@WebAppConfiguration -@DirtiesContext -public class RabbitAndRedisBinderApplicationTests { - - @ClassRule - public static RabbitTestSupport rabbitTestSupport = new RabbitTestSupport(); - - @ClassRule - public static RedisTestSupport redisTestSupport = new RedisTestSupport(); - - @Autowired - private BinderFactory binderFactory; - - private final String randomGroup = UUID.randomUUID().toString(); - - @After - public void cleanUp() { - RabbitAdmin admin = new RabbitAdmin(rabbitTestSupport.getResource()); - admin.deleteQueue("binder.dataOut.default"); - admin.deleteQueue("binder.dataOut." + this.randomGroup); - admin.deleteExchange("binder.dataOut"); - } - - @Test - public void contextLoads() { - } - - @Test - public void messagingWorks() { - DirectChannel dataProducer = new DirectChannel(); - binderFactory.getBinder("redis").bindProducer("dataIn", dataProducer, null); - - QueueChannel dataConsumer = new QueueChannel(); - binderFactory.getBinder("rabbit").bindConsumer("dataOut", this.randomGroup, - dataConsumer, null); - - String testPayload = "testFoo" + this.randomGroup; - dataProducer.send(MessageBuilder.withPayload(testPayload).build()); - - Message receive = dataConsumer.receive(2000); - Assert.assertThat(receive, Matchers.notNullValue()); - Assert.assertThat(receive.getPayload(), CoreMatchers.equalTo(testPayload)); - } - -} diff --git a/spring-cloud-stream-samples/pom.xml b/spring-cloud-stream-samples/pom.xml deleted file mode 100644 index 281fa22fe..000000000 --- a/spring-cloud-stream-samples/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - 4.0.0 - - spring-cloud-stream-samples - pom - http://cloud.spring.io/spring-cloud-stream/ - - Pivotal Software, Inc. - http://www.spring.io - - - org.springframework.cloud - spring-cloud-stream-parent - 1.0.0.BUILD-SNAPSHOT - - - UTF-8 - 1.8 - - - source - sink - transform - double - extended - multibinder - multibinder-differentsystems - rxjava-processor - - - - - org.springframework.cloud - spring-cloud-stream-sample-source - 1.0.0.BUILD-SNAPSHOT - - - org.springframework.cloud - spring-cloud-stream-sample-sink - 1.0.0.BUILD-SNAPSHOT - - - org.springframework.cloud - spring-cloud-stream-sample-transform - 1.0.0.BUILD-SNAPSHOT - - - - - - - - - maven-deploy-plugin - - true - - - - - - diff --git a/spring-cloud-stream-samples/rxjava-processor/pom.xml b/spring-cloud-stream-samples/rxjava-processor/pom.xml deleted file mode 100644 index 3a21375c0..000000000 --- a/spring-cloud-stream-samples/rxjava-processor/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - 4.0.0 - - spring-cloud-stream-sample-rxjava - jar - - spring-cloud-stream-sample-rxjava - Demo project for RxJava module - - - org.springframework.cloud - spring-cloud-stream-samples - 1.0.0.BUILD-SNAPSHOT - - - - UTF-8 - demo.RxJavaApplication - 1.8 - - - - - org.springframework.cloud - spring-cloud-stream-rxjava - 1.0.0.BUILD-SNAPSHOT - - - org.springframework.cloud - spring-cloud-stream-binder-redis - - - org.springframework.boot - spring-boot-starter-redis - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - exec - - - - - - diff --git a/spring-cloud-stream-samples/rxjava-processor/src/main/java/demo/RxJavaApplication.java b/spring-cloud-stream-samples/rxjava-processor/src/main/java/demo/RxJavaApplication.java deleted file mode 100644 index 78fc2149d..000000000 --- a/spring-cloud-stream-samples/rxjava-processor/src/main/java/demo/RxJavaApplication.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -/** - * @author Ilayaperumal Gopinathan - */ -@SpringBootApplication -public class RxJavaApplication { - - public static void main(String[] args) { - SpringApplication.run(RxJavaApplication.class, args); - } - -} diff --git a/spring-cloud-stream-samples/rxjava-processor/src/main/java/demo/RxJavaTransformer.java b/spring-cloud-stream-samples/rxjava-processor/src/main/java/demo/RxJavaTransformer.java deleted file mode 100644 index 8ed814677..000000000 --- a/spring-cloud-stream-samples/rxjava-processor/src/main/java/demo/RxJavaTransformer.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.cloud.stream.annotation.rxjava.EnableRxJavaProcessor; -import org.springframework.cloud.stream.annotation.rxjava.RxJavaProcessor; -import org.springframework.context.annotation.Bean; - -@EnableRxJavaProcessor -public class RxJavaTransformer { - - private static Logger logger = LoggerFactory.getLogger(RxJavaTransformer.class); - - @Bean - public RxJavaProcessor processor() { - return inputStream -> inputStream.map(data -> { - logger.info("Got data = " + data); - return data; - }).buffer(5).map(data -> String.valueOf(avg(data))); - } - - private static Double avg(List data) { - double sum = 0; - double count = 0; - for(String d : data) { - count++; - sum += Double.valueOf(d); - } - return sum/count; - } - -} diff --git a/spring-cloud-stream-samples/rxjava-processor/src/main/resources/application.yml b/spring-cloud-stream-samples/rxjava-processor/src/main/resources/application.yml deleted file mode 100644 index 8668638ef..000000000 --- a/spring-cloud-stream-samples/rxjava-processor/src/main/resources/application.yml +++ /dev/null @@ -1,8 +0,0 @@ -server: - port: 8082 -spring: - cloud: - stream: - bindings: - output: xformed - input: testtock diff --git a/spring-cloud-stream-samples/rxjava-processor/src/test/java/demo/ModuleApplicationTests.java b/spring-cloud-stream-samples/rxjava-processor/src/test/java/demo/ModuleApplicationTests.java deleted file mode 100644 index 4e6887ba4..000000000 --- a/spring-cloud-stream-samples/rxjava-processor/src/test/java/demo/ModuleApplicationTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = RxJavaApplication.class) -@WebAppConfiguration -@DirtiesContext -public class ModuleApplicationTests { - - @Test - public void contextLoads() { - } - -} diff --git a/spring-cloud-stream-samples/sink/README.md b/spring-cloud-stream-samples/sink/README.md deleted file mode 100644 index 12ae13a7c..000000000 --- a/spring-cloud-stream-samples/sink/README.md +++ /dev/null @@ -1,32 +0,0 @@ -Spring Cloud Stream Sink Sample -============================= - -In this *Spring Cloud Stream* sample, messages are received from a stream and the payload of each is logged to the console. - -## Requirements - -To run this sample, you will need to have installed: - -* Java 8 or Above - -This example requires Redis to be running on localhost. - -## Code Tour - -This sample is a Spring Boot application that uses Spring Cloud Stream to receive messages and write each payload to the console. The sink module has 2 primary components: - -* SinkApplication - the Spring Boot Main Application -* LogSink - the module that receives the data from the stream and writes it out to the console - -## Building with Maven - -Build the sample by executing: - - sink>$ mvn clean package - -## Running the Sample - -To start the sink module execute the following: - - sink>$ java -jar target/spring-cloud-stream-sample-sink-1.0.0.BUILD-SNAPSHOT-exec.jar - diff --git a/spring-cloud-stream-samples/sink/pom.xml b/spring-cloud-stream-samples/sink/pom.xml deleted file mode 100644 index bb29a7f9a..000000000 --- a/spring-cloud-stream-samples/sink/pom.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - 4.0.0 - - spring-cloud-stream-sample-sink - jar - spring-cloud-stream-sample-sink - Demo project for Sink module - - - org.springframework.cloud - spring-cloud-stream-samples - 1.0.0.BUILD-SNAPSHOT - - - - demo.SinkApplication - - - - - org.springframework.cloud - spring-cloud-stream - - - org.springframework.cloud - spring-cloud-stream-binder-redis - - - org.springframework.boot - spring-boot-starter-redis - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - exec - - - - - - diff --git a/spring-cloud-stream-samples/sink/src/main/java/demo/LogSink.java b/spring-cloud-stream-samples/sink/src/main/java/demo/LogSink.java deleted file mode 100644 index 8caaaf13e..000000000 --- a/spring-cloud-stream-samples/sink/src/main/java/demo/LogSink.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.messaging.Sink; -import org.springframework.integration.annotation.ServiceActivator; - -/** - * @author Dave Syer - * - */ -@EnableBinding(Sink.class) -public class LogSink { - - private static Logger logger = LoggerFactory.getLogger(LogSink.class); - - @ServiceActivator(inputChannel=Sink.INPUT) - public void loggerSink(Object payload) { - logger.info("Received: " + payload); - } - -} diff --git a/spring-cloud-stream-samples/sink/src/main/java/demo/SinkApplication.java b/spring-cloud-stream-samples/sink/src/main/java/demo/SinkApplication.java deleted file mode 100644 index 8e2c3a120..000000000 --- a/spring-cloud-stream-samples/sink/src/main/java/demo/SinkApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SinkApplication { - - public static void main(String[] args) { - SpringApplication.run(SinkApplication.class, args); - } - -} diff --git a/spring-cloud-stream-samples/sink/src/main/resources/application.yml b/spring-cloud-stream-samples/sink/src/main/resources/application.yml deleted file mode 100644 index d469a0f5b..000000000 --- a/spring-cloud-stream-samples/sink/src/main/resources/application.yml +++ /dev/null @@ -1,12 +0,0 @@ -server: - port: 8081 -spring: - cloud: - stream: - bindings: - input: testtock - # uncomment below to have this module consume from a specific partition - # in the range of 0 to N-1, where N is the upstream module's partitionCount - #consumerProperties: - # partitionIndex: 1 - \ No newline at end of file diff --git a/spring-cloud-stream-samples/sink/src/test/java/demo/ModuleApplicationTests.java b/spring-cloud-stream-samples/sink/src/test/java/demo/ModuleApplicationTests.java deleted file mode 100644 index f2a02f225..000000000 --- a/spring-cloud-stream-samples/sink/src/test/java/demo/ModuleApplicationTests.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.cloud.stream.annotation.Bindings; -import org.springframework.cloud.stream.annotation.Output; -import org.springframework.cloud.stream.messaging.Sink; -import org.springframework.cloud.stream.messaging.Source; -import org.springframework.messaging.MessageChannel; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = SinkApplication.class) -@WebAppConfiguration -@DirtiesContext -public class ModuleApplicationTests { - - @Autowired - @Bindings(LogSink.class) - private Sink sink; - - @Autowired - private Sink same; - - @Output(Source.OUTPUT) - private MessageChannel output; - - @Test - public void contextLoads() { - assertNotNull(this.sink.input()); - } - -} diff --git a/spring-cloud-stream-samples/source/README.md b/spring-cloud-stream-samples/source/README.md deleted file mode 100644 index ce59b9fe5..000000000 --- a/spring-cloud-stream-samples/source/README.md +++ /dev/null @@ -1,38 +0,0 @@ -Spring Cloud Stream Source Sample -============================= - -In this *Spring Cloud Stream* sample, a timestamp is published on an interval determined by the fixedDelay property. - -## Requirements - -To run this sample, you will need to have installed: - -* Java 8 or Above - -This example requires Redis to be running on localhost. - -## Code Tour - -This sample is a Spring Boot application that uses Spring Cloud Stream to publish timestamp data. The source module has 3 primary components: - -* SourceApplication - the Spring Boot Main Application -* TimeSource - the module that will generate the timestamp and post the message to the stream -* TimeSourceOptionsMetadata - defines the configurations that are available to setup the TimeSource - * format - how to render the current time, using SimpleDateFormat - * fixedDelay - time delay between messages - * initialDelay - delay before the first message - * timeUnit - the time unit for the fixed and initial delays - * maxMessages - the maximum messages per poll; -1 for unlimited - -## Building with Maven - -Build the sample by executing: - - source>$ mvn clean package - -## Running the Sample - -To start the source module execute the following: - - source>$ java -jar target/spring-cloud-stream-sample-source-1.0.0.BUILD-SNAPSHOT-exec.jar - diff --git a/spring-cloud-stream-samples/source/pom.xml b/spring-cloud-stream-samples/source/pom.xml deleted file mode 100644 index 3ce3d1df0..000000000 --- a/spring-cloud-stream-samples/source/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - 4.0.0 - - spring-cloud-stream-sample-source - jar - spring-cloud-stream-sample-source - Demo project for source module - - - org.springframework.cloud - spring-cloud-stream-samples - 1.0.0.BUILD-SNAPSHOT - - - - demo.SourceApplication - - - - - org.springframework.cloud - spring-cloud-stream - - - org.springframework.cloud - spring-cloud-stream-binder-redis - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.springframework.boot - spring-boot-starter-redis - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - exec - - - - - - diff --git a/spring-cloud-stream-samples/source/src/main/java/demo/DateFormat.java b/spring-cloud-stream-samples/source/src/main/java/demo/DateFormat.java deleted file mode 100644 index 17e134cd5..000000000 --- a/spring-cloud-stream-samples/source/src/main/java/demo/DateFormat.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; -import java.text.SimpleDateFormat; - -import javax.validation.Constraint; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.Payload; - -/** - * The annotated String must be a valid {@link java.text.SimpleDateFormat} pattern. - * - * @author Eric Bottard - */ -@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) -@Retention(RUNTIME) -@Documented -@Constraint(validatedBy = {DateFormat.DateFormatValidator.class}) -public @interface DateFormat { - - String DEFAULT_MESSAGE = ""; - - String message() default DEFAULT_MESSAGE; - - Class[] groups() default {}; - - Class[] payload() default {}; - - - /** - * Defines several {@link DateFormat} annotations on the same element. - * - * @see DateFormat - */ - @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) - @Retention(RUNTIME) - @Documented - @interface List { - - DateFormat[] value(); - } - - public static class DateFormatValidator implements ConstraintValidator { - - private String message; - - @Override - public void initialize(DateFormat constraintAnnotation) { - this.message = constraintAnnotation.message(); - } - - @Override - public boolean isValid(CharSequence value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - try { - new SimpleDateFormat(value.toString()); - } - catch (IllegalArgumentException e) { - if (DEFAULT_MESSAGE.equals(this.message)) { - context.disableDefaultConstraintViolation(); - context.buildConstraintViolationWithTemplate(e.getMessage()).addConstraintViolation(); - } - return false; - } - return true; - } - } - -} diff --git a/spring-cloud-stream-samples/source/src/main/java/demo/SourceApplication.java b/spring-cloud-stream-samples/source/src/main/java/demo/SourceApplication.java deleted file mode 100644 index 277052040..000000000 --- a/spring-cloud-stream-samples/source/src/main/java/demo/SourceApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SourceApplication { - - public static void main(String[] args) { - SpringApplication.run(SourceApplication.class, args); - } - -} diff --git a/spring-cloud-stream-samples/source/src/main/java/demo/TimeSource.java b/spring-cloud-stream-samples/source/src/main/java/demo/TimeSource.java deleted file mode 100644 index 77d909aeb..000000000 --- a/spring-cloud-stream-samples/source/src/main/java/demo/TimeSource.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.messaging.Source; -import org.springframework.context.annotation.Bean; -import org.springframework.integration.annotation.InboundChannelAdapter; -import org.springframework.integration.annotation.Poller; -import org.springframework.integration.core.MessageSource; -import org.springframework.messaging.support.GenericMessage; - -/** - * @author Dave Syer - * @author Glenn Renfro - * - */ -@EnableBinding(Source.class) -@EnableConfigurationProperties(TimeSourceOptionsMetadata.class) -public class TimeSource { - - @Autowired - private TimeSourceOptionsMetadata options; - - @Bean - @InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1")) - public MessageSource timerMessageSource() { - return () -> new GenericMessage<>(new SimpleDateFormat(this.options.getFormat()).format(new Date())); - } - -} diff --git a/spring-cloud-stream-samples/source/src/main/java/demo/TimeSourceOptionsMetadata.java b/spring-cloud-stream-samples/source/src/main/java/demo/TimeSourceOptionsMetadata.java deleted file mode 100644 index d88fda690..000000000 --- a/spring-cloud-stream-samples/source/src/main/java/demo/TimeSourceOptionsMetadata.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2013-2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import javax.validation.constraints.Min; -import javax.validation.constraints.Pattern; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Describes options to the {@code time} source module. - * - * @author Eric Bottard - * @author Gary Russell - */ -@ConfigurationProperties -public class TimeSourceOptionsMetadata { - - /** - * how to render the current time, using SimpleDateFormat - */ - private String format = "yyyy-MM-dd HH:mm:ss"; - - /** - * time delay between messages, expressed in TimeUnits (seconds by default) - */ - private int fixedDelay = 1; - - /** - * an initial delay when using a fixed delay trigger, expressed in TimeUnits (seconds by default) - */ - private int initialDelay = 0; - - /** - * the time unit for the fixed and initial delays - */ - private String timeUnit = "SECONDS"; - - /** - * the maximum messages per poll; -1 for unlimited - */ - long maxMessages = 1; - - public long getMaxMessages() { - return this.maxMessages; - } - - public void setMaxMessages(long maxMessages) { - this.maxMessages = maxMessages; - } - - @Min(0) - public int getInitialDelay() { - return this.initialDelay; - } - - public void setInitialDelay(int initialDelay) { - this.initialDelay = initialDelay; - } - - @Pattern(regexp = "(?i)(NANOSECONDS|MICROSECONDS|MILLISECONDS|SECONDS|MINUTES|HOURS|DAYS)", - message = "timeUnit must be one of NANOSECONDS, MICROSECONDS, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS (case-insensitive)") - public String getTimeUnit() { - return this.timeUnit; - } - - public void setTimeUnit(String timeUnit) { - this.timeUnit = timeUnit.toUpperCase(); - } - - @DateFormat - public String getFormat() { - return this.format; - } - - public void setFormat(String format) { - this.format = format; - } - - public int getFixedDelay() { - return this.fixedDelay; - } - - public void setFixedDelay(int fixedDelay) { - this.fixedDelay = fixedDelay; - } - - -} diff --git a/spring-cloud-stream-samples/source/src/main/resources/application.yml b/spring-cloud-stream-samples/source/src/main/resources/application.yml deleted file mode 100644 index 72f476dff..000000000 --- a/spring-cloud-stream-samples/source/src/main/resources/application.yml +++ /dev/null @@ -1,24 +0,0 @@ -server: - port: 8080 -fixedDelay: 5000 -spring: - cloud: - stream: - bindings: - output: - destination: testtock - contentType: text/plain - # uncomment below to use the last digit of the seconds as a partition key - # hashcode(key) % N is then applied with N being the partitionCount value - # thus, even seconds should go to the 0 queue, odd seconds to the 1 queue - #producerProperties: - # partitionKeyExpression: payload.charAt(payload.length()-1) - # partitionCount: 2 - ---- -spring: - profiles: extended - cloud: - stream: - bindings: - output: xformed diff --git a/spring-cloud-stream-samples/source/src/test/java/demo/ModuleApplicationTests.java b/spring-cloud-stream-samples/source/src/test/java/demo/ModuleApplicationTests.java deleted file mode 100644 index ae245b541..000000000 --- a/spring-cloud-stream-samples/source/src/test/java/demo/ModuleApplicationTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = SourceApplication.class) -@WebAppConfiguration -@DirtiesContext -public class ModuleApplicationTests { - - @Test - public void contextLoads() { - } - -} diff --git a/spring-cloud-stream-samples/transform/pom.xml b/spring-cloud-stream-samples/transform/pom.xml deleted file mode 100644 index a0bd1d666..000000000 --- a/spring-cloud-stream-samples/transform/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - 4.0.0 - - spring-cloud-stream-sample-transform - jar - - spring-cloud-stream-sample-transform - Demo project for transform module - - - org.springframework.cloud - spring-cloud-stream-samples - 1.0.0.BUILD-SNAPSHOT - - - - demo.TransformApplication - - - - - org.springframework.cloud - spring-cloud-stream - - - org.springframework.cloud - spring-cloud-stream-binder-redis - - - org.springframework.boot - spring-boot-starter-redis - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - exec - - - - - - diff --git a/spring-cloud-stream-samples/transform/src/main/java/demo/LoggingTransformer.java b/spring-cloud-stream-samples/transform/src/main/java/demo/LoggingTransformer.java deleted file mode 100644 index 9bcfdc587..000000000 --- a/spring-cloud-stream-samples/transform/src/main/java/demo/LoggingTransformer.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.messaging.Processor; -import org.springframework.integration.annotation.ServiceActivator; - -/** - * @author Dave Syer - * - */ -@EnableBinding(Processor.class) -@ConfigurationProperties("module.logging") -public class LoggingTransformer { - - private static Logger logger = LoggerFactory.getLogger(LoggingTransformer.class); - - /** - * The name to include in the log message - */ - private String name = "logging"; - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - @ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT) - public Object transform(Object payload) { - logger.info("Transformed by " + this.name + ": " + payload); - return payload; - } - -} diff --git a/spring-cloud-stream-samples/transform/src/main/java/demo/TransformApplication.java b/spring-cloud-stream-samples/transform/src/main/java/demo/TransformApplication.java deleted file mode 100644 index 48e007b6a..000000000 --- a/spring-cloud-stream-samples/transform/src/main/java/demo/TransformApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class TransformApplication { - - public static void main(String[] args) { - SpringApplication.run(TransformApplication.class, args); - } - -} diff --git a/spring-cloud-stream-samples/transform/src/main/resources/application.yml b/spring-cloud-stream-samples/transform/src/main/resources/application.yml deleted file mode 100644 index f62709eea..000000000 --- a/spring-cloud-stream-samples/transform/src/main/resources/application.yml +++ /dev/null @@ -1,9 +0,0 @@ -server: - port: 8082 -spring: - cloud: - stream: - bindings: - output: xformed - input: testtock - \ No newline at end of file diff --git a/spring-cloud-stream-samples/transform/src/test/java/demo/ModuleApplicationTests.java b/spring-cloud-stream-samples/transform/src/test/java/demo/ModuleApplicationTests.java deleted file mode 100644 index c1ee7d658..000000000 --- a/spring-cloud-stream-samples/transform/src/test/java/demo/ModuleApplicationTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = TransformApplication.class) -@WebAppConfiguration -@DirtiesContext -public class ModuleApplicationTests { - - @Test - public void contextLoads() { - } - -}