Skip to content

Instantly share code, notes, and snippets.

@ftrossbach
ftrossbach / Vertx.java
Created March 17, 2017 13:04
VertxCluster
Vertx.clusteredVertx(new VertxOptions().setClusterManager(new HazelcastClusterManager()), handler -> {
if(handler.succeeded()){
Vertx vertx = handler.result();
});
{
"hostInfo":{
"host":"1.2.3.4",
"port":42
},
"stateStoreNames":[
"totalVisitCount",
"hourlyVisitCount",
"sessionVisitCount"
],
@ftrossbach
ftrossbach / Topology.java
Last active March 10, 2017 16:03
A simplified Kafka Streams topology
KStreamBuilder builder = new KStreamBuilder();
KStream<String, Long> visitsStream = builder.stream(Serdes.String(), Serdes.Long(), "visitsTopic");
KGroupedStream<String, Long> groupedStream = visitsStream.groupByKey();
KTable<String, Long> totalCount = groupedStream.count("totalVisitCount");
KTable<Windowed<String>, Long> windowedCount = groupedStream.count(TimeWindows.of(60 * 60 * 1000), "hourlyVisitCount");
groupedStream.count(SessionWindows.with(60 * 1000), "sessionVisitCount");