mirror of
https://github.com/wahyd4/spring-cloud-stream-samples.git
synced 2026-08-09 05:16:18 +10:00
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener). # Fixed URLs ## Fixed Success These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended. * http://maven.apache.org/xsd/maven-4.0.0.xsd with 19 occurrences migrated to: https://maven.apache.org/xsd/maven-4.0.0.xsd ([https](https://maven.apache.org/xsd/maven-4.0.0.xsd) result 200). * http://www.apache.org/licenses/LICENSE-2.0 with 6 occurrences migrated to: https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200). * http://www.spring.io with 1 occurrences migrated to: https://www.spring.io ([https](https://www.spring.io) result 301). * http://repo.spring.io/libs-milestone-local with 5 occurrences migrated to: https://repo.spring.io/libs-milestone-local ([https](https://repo.spring.io/libs-milestone-local) result 302). * http://repo.spring.io/libs-release-local with 1 occurrences migrated to: https://repo.spring.io/libs-release-local ([https](https://repo.spring.io/libs-release-local) result 302). * http://repo.spring.io/libs-snapshot-local with 2 occurrences migrated to: https://repo.spring.io/libs-snapshot-local ([https](https://repo.spring.io/libs-snapshot-local) result 302). * http://repo.spring.io/release with 1 occurrences migrated to: https://repo.spring.io/release ([https](https://repo.spring.io/release) result 302). # Ignored These URLs were intentionally ignored. * http://maven.apache.org/POM/4.0.0 with 38 occurrences * http://www.w3.org/2001/XMLSchema-instance with 19 occurrences
== What is this app? This is an example of a Spring Cloud Stream processor using Kafka Streams support. The example is based on the word count application from the https://github.com/confluentinc/examples/blob/3.2.x/kafka-streams/src/main/java/io/confluent/examples/streams/WordCountLambdaExample.java[reference documentation]. It uses a single input and a single output. In essence, the application receives text messages from an input topic and computes word occurrence counts in a configurable time window and report that in an output topic. This sample uses lambda expressions and thus requires Java 8+. ==== Starting Kafka in a docker container * Skip steps 1-3 if you already have a non-Docker Kafka environment. 1. Go to the docker directory in this repo and invoke the command `docker-compose up -d`. 2. Ensure that in the docker directory and then invoke the script `start-kafka-shell.sh` 3. cd $KAFKA_HOME 4. Start the console producer: + Assuming that you are running kafka on a docker container on mac osx. Change the zookeeper IP address accordingly otherwise. + `bin/kafka-console-producer.sh --broker-list 192.168.99.100:9092 --topic words` 5. Start the console consumer: + Assuming that you are running kafka on a docker container on mac osx. Change the zookeeper IP address accordingly otherwise. + `bin/kafka-console-consumer.sh --bootstrap-server 192.168.99.100:9092 --topic counts` === Running the app: Go to the root of the repository and do: `./mvnw clean package` `java -jar target/kstream-word-count-0.0.1-SNAPSHOT.jar --spring.cloud.stream.kstream.timeWindow.length=5000` * By default we use the docker container IP (mac osx specific) in the `application.yml` for Kafka broker and zookeeper. Change it in `application.yml` (which requires a rebuild) or pass them as runtime arguments as below. `spring.cloud.stream.kstream.binder.brokers=<Broker IP Address>` + `spring.cloud.stream.kstream.binder.zkNodes=<Zookeeper IP Address>` Enter some text in the console producer and watch the output in the console consumer. In order to switch to a hopping window, you can use the `spring.cloud.stream.kstream.timeWindow.advanceBy` (value in milliseconds). This will create an overlapped hopping windows depending on the value you provide. Here is an example with 2 overlapping windows (window length of 10 seconds and a hop (advance) by 5 seconds: `java -jar target/kstream-word-count-0.0.1-SNAPSHOT.jar --spring.cloud.stream.kstream.timeWindow.length=10000 --spring.cloud.stream.kstream.timeWindow.advanceBy=5000`