Skip to content

Instantly share code, notes, and snippets.

View danielkec's full-sized avatar
🚀

Daniel Kec danielkec

🚀
View GitHub Profile
AtomicInteger sum = new AtomicInteger();
Flux<Integer> flux = Flux.just("1", "2", "3", "4", "5")
.map(Integer::parseInt);
ReactiveStreams.fromPublisher(flux)
.limit(3)
.forEach(sum::addAndGet)
.run()
.whenComplete((r, t) -> System.out.println("Sum: " + sum.get()));
@Outgoing("int-channel")
public Publisher<Integer> produceInts() {
return Flowable.just(1, 2, 3);
}
@Incoming("int-channel")
public void consumeInt(Integer value) {
System.out.println("Consuming Integer: " + value);
}
<dependency>
<groupId>io.helidon.microprofile.reactive-streams</groupId>
<artifactId>helidon-microprofile-reactive-streams</artifactId>
<version>${helidon.version}</version>
</dependency>
Multi.just(1, 2, 3, 4, 5)
.flatMap(i -> Multi.just(i, i))
.limit(4)
.distinct()
.forEach(System.out::println);
> 1
> 2
package io.helidon.reactive.jmh;
import java.util.List;
import java.util.concurrent.Flow;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import io.helidon.common.reactive.BufferedEmittingPublisher;
import io.helidon.common.reactive.Multi;
import io.helidon.common.reactive.OriginThreadPublisher;
@danielkec
danielkec / gist:8a12cc970ec872c3174b4f2b7ce4a7c8
Created June 17, 2020 18:50
SE Messaging with MP config
mp.messaging:
incoming.from-kafka:
connector: helidon-kafka
topic: messaging-test-topic-1
auto.offset.reset: latest
enable.auto.commit: true
outgoing.to-kafka:
connector: helidon-kafka
@danielkec
danielkec / helidon-kafka-article-01.yaml
Last active June 22, 2020 19:40
Lets jump to simple example:
mp.messaging:
incoming.from-kafka:
connector: helidon-kafka
topic: messaging-test-topic-1
auto.offset.reset: latest
enable.auto.commit: true
group.id: example-group-1
outgoing.to-kafka:
<dependency>
<groupId>io.helidon.messaging</groupId>
<artifactId>helidon-messaging</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.messaging.kafka</groupId>
<artifactId>helidon-messaging-kafka</artifactId>
</dependency>
@ApplicationScoped
public class ExampleBean {
@Incoming("from-kafka")
public void broadcast(String payload) {
System.out.println("Kafka says: " + payload);
}