</parent>
<groupId>de.juplo.kafka.wordcount</groupId>
<artifactId>counter</artifactId>
- <version>1.0.1</version>
+ <version>1.1.0</version>
<name>Wordcount-Counter</name>
<description>Word-counting stream-processor of the multi-user wordcount-example</description>
<properties>
{
private String bootstrapServer = "localhost:9092";
private String applicationId = "counter";
- private String inputTopic = "recordings";
+ private String inputTopic = "words";
private String outputTopic = "countings";
}
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
-import java.util.Arrays;
import java.util.Properties;
import java.util.concurrent.CompletableFuture;
-import java.util.regex.Pattern;
import static org.apache.kafka.streams.errors.StreamsUncaughtExceptionHandler.StreamThreadExceptionResponse.SHUTDOWN_CLIENT;
@Component
public class CounterStreamProcessor
{
- final static Pattern PATTERN = Pattern.compile("\\W+");
-
public final KafkaStreams streams;
KStream<String, String> source = builder.stream(properties.getInputTopic());
source
- .flatMapValues(sentence -> Arrays.asList(PATTERN.split(sentence)))
.map((username, word) ->
{
try