Skip to content

Instantly share code, notes, and snippets.

@danielkec
Created June 22, 2020 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielkec/88ccb91a863f25570c4b4c2f629cd44d to your computer and use it in GitHub Desktop.
Save danielkec/88ccb91a863f25570c4b4c2f629cd44d to your computer and use it in GitHub Desktop.
Channel<String> fromKafka = Channel.create("from-kafka");
KafkaConnector kafkaConnector = KafkaConnector.create();
Messaging messaging = Messaging.builder()
.connector(kafkaConnector)
.subscriber(fromKafka, ReactiveStreams.<Message<String>>builder()
//Apply back-pressure, flatMapCompletionStage requests one by one
.flatMapCompletionStage(message -> {
return CompletableFuture.runAsync(() -> {
//Do something lengthy
Multi.timer(300, TimeUnit.MILLISECONDS, executor)
.first()
.await();
//Acknowledge message has been consumed
message.ack();
});
})
.ignore())
.build()
.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment