From 03e0a6b1532dee94af720553205223cb07ed45d9 Mon Sep 17 00:00:00 2001 From: Marius Bogoevici Date: Wed, 15 Jun 2016 09:46:14 -0400 Subject: [PATCH] Use Spring Cloud Stream 1.0.2.RELEASE for samples - switch to RabbitMQ binder --- README.adoc | 2 +- double/pom.xml | 2 +- .../processor/ProcessorApplication.java | 27 +++++++++ .../processor/ProcessorModuleDefinition.java | 34 +++++++++++ .../src/main/java/demo/DoubleApplication.java | 9 ++- multi-io/pom.xml | 6 +- multibinder-differentsystems/pom.xml | 4 -- multibinder/pom.xml | 1 + pom.xml | 58 ++----------------- rxjava-processor/pom.xml | 4 +- sink/pom.xml | 6 +- source/pom.xml | 2 +- source/src/main/java/demo/TimeSource.java | 7 +-- stream-listener/pom.xml | 6 +- transform/pom.xml | 6 +- 15 files changed, 84 insertions(+), 90 deletions(-) create mode 100644 double/src/main/java/config/processor/ProcessorApplication.java create mode 100644 double/src/main/java/config/processor/ProcessorModuleDefinition.java diff --git a/README.adoc b/README.adoc index 74a3adc..a98c6fe 100644 --- a/README.adoc +++ b/README.adoc @@ -1,6 +1,6 @@ == Samples -There are several samples, all running on the redis transport (so you need redis running locally to test them). +There are several samples, all running on the RabbitMQ transport (so you need RabbitMQ running locally to test them). To build the samples do: diff --git a/double/pom.xml b/double/pom.xml index 0555a47..52e04ed 100644 --- a/double/pom.xml +++ b/double/pom.xml @@ -37,7 +37,7 @@ org.springframework.cloud - spring-cloud-stream-binder-redis + spring-cloud-stream-binder-rabbit diff --git a/double/src/main/java/config/processor/ProcessorApplication.java b/double/src/main/java/config/processor/ProcessorApplication.java new file mode 100644 index 0000000..5bd2c51 --- /dev/null +++ b/double/src/main/java/config/processor/ProcessorApplication.java @@ -0,0 +1,27 @@ +/* + * Copyright 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 config.processor; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author Marius Bogoevici + */ +@SpringBootApplication +public class ProcessorApplication { + +} diff --git a/double/src/main/java/config/processor/ProcessorModuleDefinition.java b/double/src/main/java/config/processor/ProcessorModuleDefinition.java new file mode 100644 index 0000000..2cc01e1 --- /dev/null +++ b/double/src/main/java/config/processor/ProcessorModuleDefinition.java @@ -0,0 +1,34 @@ +/* + * Copyright 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 config.processor; + +import org.springframework.cloud.stream.annotation.EnableBinding; +import org.springframework.cloud.stream.messaging.Processor; +import org.springframework.integration.annotation.Transformer; +import org.springframework.messaging.Message; + +/** + * @author Marius Bogoevici + */ +@EnableBinding(Processor.class) +public class ProcessorModuleDefinition { + + @Transformer + public Message transform(Message inbound) { + return inbound; + } +} diff --git a/double/src/main/java/demo/DoubleApplication.java b/double/src/main/java/demo/DoubleApplication.java index b82d1f2..2618445 100644 --- a/double/src/main/java/demo/DoubleApplication.java +++ b/double/src/main/java/demo/DoubleApplication.java @@ -16,18 +16,21 @@ package demo; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.stream.aggregate.AggregateApplicationBuilder; - import config.sink.SinkApplication; import config.source.SourceApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.stream.aggregate.AggregateApplicationBuilder; +import org.springframework.cloud.stream.messaging.Processor; +import org.springframework.context.ConfigurableApplicationContext; + @SpringBootApplication public class DoubleApplication { public static void main(String[] args) { new AggregateApplicationBuilder(). from(SourceApplication.class).args("--fixedDelay=5000") + .via(Processor.class) .to(SinkApplication.class).args("--debug=true").run("--spring.application.name=aggregate-test"); } diff --git a/multi-io/pom.xml b/multi-io/pom.xml index b10a3b0..cdc4285 100644 --- a/multi-io/pom.xml +++ b/multi-io/pom.xml @@ -25,11 +25,7 @@ org.springframework.cloud - spring-cloud-stream-binder-redis - - - org.springframework.boot - spring-boot-starter-redis + spring-cloud-stream-binder-rabbit org.springframework.boot diff --git a/multibinder-differentsystems/pom.xml b/multibinder-differentsystems/pom.xml index 35addd9..c5aafbf 100644 --- a/multibinder-differentsystems/pom.xml +++ b/multibinder-differentsystems/pom.xml @@ -36,10 +36,6 @@ org.springframework.cloud spring-cloud-stream-sample-sink - - org.springframework.cloud - spring-cloud-stream-binder-redis - org.springframework.cloud spring-cloud-stream-binder-kafka diff --git a/multibinder/pom.xml b/multibinder/pom.xml index 36ebe1d..f48fe37 100644 --- a/multibinder/pom.xml +++ b/multibinder/pom.xml @@ -37,6 +37,7 @@ org.springframework.cloud spring-cloud-stream-binder-redis + 1.0.0.RELEASE org.springframework.cloud diff --git a/pom.xml b/pom.xml index 42124e4..129d2cb 100644 --- a/pom.xml +++ b/pom.xml @@ -13,12 +13,11 @@ org.springframework.cloud spring-cloud-build - 1.1.0.RC2 + 1.1.1.RELEASE UTF-8 - 1.0.0.RC3 - 1.0.0.RC2 + 1.0.2.RELEASE 1.8 @@ -58,8 +57,8 @@ org.springframework.cloud - spring-cloud-stream-binder-redis - ${spring-cloud-stream-binder-redis.version} + spring-cloud-stream-binder-rabbit + ${spring-cloud-stream.version} @@ -76,53 +75,4 @@ - - - spring - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - http://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - - diff --git a/rxjava-processor/pom.xml b/rxjava-processor/pom.xml index 3a21375..4073b1b 100644 --- a/rxjava-processor/pom.xml +++ b/rxjava-processor/pom.xml @@ -24,11 +24,11 @@ org.springframework.cloud spring-cloud-stream-rxjava - 1.0.0.BUILD-SNAPSHOT + ${spring-cloud-stream.version} org.springframework.cloud - spring-cloud-stream-binder-redis + spring-cloud-stream-binder-rabbit org.springframework.boot diff --git a/sink/pom.xml b/sink/pom.xml index bb29a7f..85f2ad8 100644 --- a/sink/pom.xml +++ b/sink/pom.xml @@ -24,11 +24,7 @@ org.springframework.cloud - spring-cloud-stream-binder-redis - - - org.springframework.boot - spring-boot-starter-redis + spring-cloud-stream-binder-rabbit org.springframework.boot diff --git a/source/pom.xml b/source/pom.xml index 504c227..d6020c6 100644 --- a/source/pom.xml +++ b/source/pom.xml @@ -24,7 +24,7 @@ org.springframework.cloud - spring-cloud-stream-binder-redis + spring-cloud-stream-binder-rabbit org.springframework.boot diff --git a/source/src/main/java/demo/TimeSource.java b/source/src/main/java/demo/TimeSource.java index 77d909a..0e851a7 100644 --- a/source/src/main/java/demo/TimeSource.java +++ b/source/src/main/java/demo/TimeSource.java @@ -41,10 +41,9 @@ 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())); + @InboundChannelAdapter(value = Source.OUTPUT) + public String timerMessageSource() { + return new SimpleDateFormat(this.options.getFormat()).format(new Date()); } } diff --git a/stream-listener/pom.xml b/stream-listener/pom.xml index 0b0cd49..c9f058a 100644 --- a/stream-listener/pom.xml +++ b/stream-listener/pom.xml @@ -25,11 +25,7 @@ org.springframework.cloud - spring-cloud-stream-binder-redis - - - org.springframework.boot - spring-boot-starter-redis + spring-cloud-stream-binder-rabbit org.springframework.boot diff --git a/transform/pom.xml b/transform/pom.xml index a0bd1d6..c72d39f 100644 --- a/transform/pom.xml +++ b/transform/pom.xml @@ -25,11 +25,7 @@ org.springframework.cloud - spring-cloud-stream-binder-redis - - - org.springframework.boot - spring-boot-starter-redis + spring-cloud-stream-binder-rabbit org.springframework.boot