diff --git a/spring-cloud-stream-samples/sink/README.md b/spring-cloud-stream-samples/sink/README.md new file mode 100644 index 000000000..5b0de38a5 --- /dev/null +++ b/spring-cloud-stream-samples/sink/README.md @@ -0,0 +1,30 @@ +Spring Cloud Streams Sink Sample +============================= + +In this sample for *Spring Cloud Streams* this sink module will receive messages from the stream and write the payload to console. + +## Requirements + +In order for the sample to run you will need to have installed: + +* Java 7 or Above + +## Code Tour + +This sample is a Spring Boot application that uses Spring Cloud Streams to retrieve data from a stream and write result to the console. The sink module has 2 primary components + +* SinkApplication - in which is the Spring Boot Main Application +* LogSink - the module that receives the data from the stream and writes it out to console. +## Building with Maven + +Build the sample simply by executing: + + sink>$ mvn clean package + +## Running the Sample + +This example requires a local instance of Redis to be up an running. +To start the sink module execute the following: + + sink>$ java -jar target/spring-cloud-streams-sample-sink-1.0.0.BUILD-SNAPSHOT-exec.jar + diff --git a/spring-cloud-stream-samples/source/README.md b/spring-cloud-stream-samples/source/README.md new file mode 100644 index 000000000..e628655a9 --- /dev/null +++ b/spring-cloud-stream-samples/source/README.md @@ -0,0 +1,37 @@ +Spring Cloud Streams Source Sample +============================= + +In this sample for *Spring Cloud Streams* we will post a timestamp to the stream on an interval determined by the fixedDelay configuration. + +## Requirements + +In order for the sample to run you will need to have installed: + +* Java 7 or Above + +## Code Tour + +This sample is a Spring Boot application that uses Spring Cloud Streams to send time stamp data to a stream. The source module has 3 primary components + +* SourceApplication - in which is 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, expressed in TimeUnits (seconds by default) + * initialDelay - an initial delay when using a fixed delay trigger, expressed in TimeUnits (seconds by default) + * 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 simply by executing: + + source>$ mvn clean package + +## Running the Sample + +This example requires a local instance of Redis to be up an running. +To start the source module execute the following: + + source>$ java -jar target/spring-cloud-streams-sample-source-1.0.0.BUILD-SNAPSHOT-exec.jar + diff --git a/spring-cloud-stream-samples/source/src/main/java/source/TimeSource.java b/spring-cloud-stream-samples/source/src/main/java/source/TimeSource.java index 4047624be..36894dcc1 100644 --- a/spring-cloud-stream-samples/source/src/main/java/source/TimeSource.java +++ b/spring-cloud-stream-samples/source/src/main/java/source/TimeSource.java @@ -16,24 +16,23 @@ package source; -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.EnableModule; import org.springframework.cloud.stream.annotation.Output; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.integration.annotation.InboundChannelAdapter; import org.springframework.integration.annotation.Poller; -import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.core.MessageSource; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.support.GenericMessage; +import java.text.SimpleDateFormat; +import java.util.Date; + /** * @author Dave Syer + * @author Glenn Renfro * */ @EnableModule diff --git a/spring-cloud-stream-samples/source/src/main/resources/application.yml b/spring-cloud-stream-samples/source/src/main/resources/application.yml index 2debefb34..841c5b3e4 100644 --- a/spring-cloud-stream-samples/source/src/main/resources/application.yml +++ b/spring-cloud-stream-samples/source/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 8081 + port: 8080 fixedDelay: 5000 spring: cloud: diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/RabbitServiceConfiguration.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/RabbitServiceConfiguration.java index 45633e324..e47e2da01 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/RabbitServiceConfiguration.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/RabbitServiceConfiguration.java @@ -33,6 +33,7 @@ import org.springframework.xd.dirt.integration.rabbit.RabbitMessageBus; * * @author Mark Fisher * @author Dave Syer + * @author Glenn Renfro */ @Configuration @ConditionalOnClass(RabbitMessageBus.class) @@ -49,7 +50,7 @@ public class RabbitServiceConfiguration { return new CloudFactory().getCloud(); } @Bean - ConnectionFactory redisConnectionFactory(Cloud cloud) { + ConnectionFactory rabbitConnectionFactory(Cloud cloud) { return cloud.getSingletonServiceConnector(ConnectionFactory.class, null); } }