-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(next): Update starters and extract common reusable code to an a…
…ditional module (#119) * chore(next): Update starters and extract common reusable code to an additional module
- Loading branch information
1 parent
7c202c5
commit 5e093a5
Showing
46 changed files
with
2,664 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 7 additions & 4 deletions
11
...src/main/java/org/reactivecommons/async/kafka/communications/ReactiveMessageListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
package org.reactivecommons.async.kafka.communications; | ||
|
||
import lombok.AllArgsConstructor; | ||
import org.apache.kafka.clients.consumer.ConsumerConfig; | ||
import reactor.core.publisher.Flux; | ||
import reactor.kafka.receiver.KafkaReceiver; | ||
import reactor.kafka.receiver.ReceiverOptions; | ||
import reactor.kafka.receiver.ReceiverRecord; | ||
|
||
import java.util.List; | ||
|
||
import static org.apache.kafka.clients.consumer.ConsumerConfig.DEFAULT_MAX_POLL_RECORDS; | ||
import static org.apache.kafka.clients.consumer.ConsumerConfig.GROUP_ID_CONFIG; | ||
import static org.apache.kafka.clients.consumer.ConsumerConfig.MAX_POLL_RECORDS_CONFIG; | ||
|
||
|
||
@AllArgsConstructor | ||
public class ReactiveMessageListener { | ||
private final ReceiverOptions<String, byte[]> receiverOptions; | ||
|
||
public Flux<ReceiverRecord<String, byte[]>> listen(String groupId, List<String> topics) { // Notification events | ||
ReceiverOptions<String, byte[]> options = receiverOptions.consumerProperty(ConsumerConfig.GROUP_ID_CONFIG, groupId); | ||
ReceiverOptions<String, byte[]> options = receiverOptions.consumerProperty(GROUP_ID_CONFIG, groupId); | ||
return KafkaReceiver.create(options.subscription(topics)) | ||
.receive(); | ||
} | ||
|
||
public int getMaxConcurrency() { | ||
Object property = receiverOptions.consumerProperty(ConsumerConfig.MAX_POLL_RECORDS_CONFIG); | ||
Object property = receiverOptions.consumerProperty(MAX_POLL_RECORDS_CONFIG); | ||
if (property instanceof Integer) { | ||
return (int) property; | ||
} | ||
return ConsumerConfig.DEFAULT_MAX_POLL_RECORDS; | ||
return DEFAULT_MAX_POLL_RECORDS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.