From f709a4e08a1e861217004deb45e4949aaa0b9516 Mon Sep 17 00:00:00 2001 From: markfisher Date: Thu, 19 Jan 2017 17:17:01 -0500 Subject: [PATCH] updated stream script for supplier and consumer --- README.adoc | 30 ++++++++++++++++++++++++++++-- scripts/stream.sh | 24 +++++++++++++++++------- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/README.adoc b/README.adoc index 170fd494e..04d2d50d1 100644 --- a/README.adoc +++ b/README.adoc @@ -49,8 +49,34 @@ curl -H "Accept: application/json" :9001/supplier curl -X POST -H "Content-Type: text/plain" -d foo :9002/consumer ---- -== Run a Stream Processing Microservice using the Function: +== Run Stream Processing Microservices: + +First register a streaming words supplier: ---- -./stream.sh -i words -o uppercaseWords -f uppercase +./registerSupplier.sh -n wordstream -f "()->Flux.intervalMillis(1000).map(i->\"message-\"+i) +---- + +Then start the source (supplier), processor (function), and sink (consumer) apps: + +---- +./stream.sh -p 9101 -s wordstream -o words +./stream.sh -p 9102 -i words -f uppercase -o uppercaseWords +./stream.sh -p 9103 -i uppercaseWords -c print +---- + +The output will appear in the console of the sink app (one message per second, converted to uppercase): + +---- +MESSAGE-0 +MESSAGE-1 +MESSAGE-2 +MESSAGE-3 +MESSAGE-4 +MESSAGE-5 +MESSAGE-6 +MESSAGE-7 +MESSAGE-8 +MESSAGE-9 +... ---- diff --git a/scripts/stream.sh b/scripts/stream.sh index db798f1d1..4e7a8b274 100755 --- a/scripts/stream.sh +++ b/scripts/stream.sh @@ -1,25 +1,35 @@ #!/bin/bash -while getopts ":i:f:o:" opt; do +while getopts ":i:s:f:c:o:p:" opt; do case $opt in i) - IN=$OPTARG + IN=--spring.cloud.stream.bindings.input.destination=$OPTARG + ;; + s) + FUNC=$OPTARG + TYPE=supplier ;; f) FUNC=$OPTARG TYPE=function ;; + c) + FUNC=$OPTARG + TYPE=consumer + ;; o) - OUT=$OPTARG + OUT=--spring.cloud.stream.bindings.output.destination=$OPTARG + ;; + p) + PORT=$OPTARG ;; esac done java -jar ../spring-cloud-function-samples/spring-cloud-function-sample-bytecode/target/function-sample-bytecode-1.0.0.BUILD-SNAPSHOT.jar\ - --management.security.enabled=false\ - --server.port=9999\ - --spring.cloud.stream.bindings.input.destination=$IN\ - --spring.cloud.stream.bindings.output.destination=$OUT\ + --server.port=$PORT\ + $IN\ + $OUT\ --function.name=$TYPE\ --function.type=$TYPE\ --function.resource=file:///tmp/function-registry/$TYPE's'/$FUNC.fun