use of io.smallrye.reactive.messaging.kafka.base.SingletonInstance in project smallrye-reactive-messaging by smallrye.
the class ReactiveKafkaConsumerTest method testOffsetResetLatest.
@Test
public void testOffsetResetLatest() throws Exception {
int count = 10;
sendMessages(0, count);
String groupId = UUID.randomUUID().toString();
MapBasedConfig config = createConsumerConfig(groupId).with("topic", topic).with(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");
SingletonInstance<KafkaConsumerRebalanceListener> listeners = new SingletonInstance<>(groupId, getKafkaConsumerRebalanceListenerAwaitingAssignation());
source = new KafkaSource<>(vertx, groupId, new KafkaConnectorIncomingConfiguration(config), listeners, CountKafkaCdiEvents.noCdiEvents, UnsatisfiedInstance.instance(), 0);
AssertSubscriber<IncomingKafkaRecord<Integer, String>> subscriber = source.getStream().invoke(this::onReceive).subscribe().withSubscriber(AssertSubscriber.create(10));
await().until(() -> {
Map<TopicPartition, Long> map = source.getConsumer().getPositions().await().indefinitely();
return map.values().stream().mapToLong(l -> l).sum() == 10;
});
subscriber.assertSubscribed().assertHasNotReceivedAnyItem();
sendMessages(count, count);
await().untilAsserted(() -> assertThat(subscriber.getItems()).hasSize(count));
await().until(() -> {
Map<TopicPartition, Long> map = source.getConsumer().getPositions().await().indefinitely();
return map.values().stream().mapToLong(l -> l).sum() == 20;
});
subscriber.cancel();
checkConsumedMessages(count, count);
}
use of io.smallrye.reactive.messaging.kafka.base.SingletonInstance in project smallrye-reactive-messaging by smallrye.
the class ClientTestBase method createSourceSeekToOffset.
public KafkaSource<Integer, String> createSourceSeekToOffset() {
String groupId = UUID.randomUUID().toString();
MapBasedConfig config = createConsumerConfig(groupId).put("topic", topic);
SingletonInstance<KafkaConsumerRebalanceListener> listeners = new SingletonInstance<>(groupId, getKafkaConsumerRebalanceListenerAwaitingAssignationAndSeekToOffset());
source = new KafkaSource<>(vertx, groupId, new KafkaConnectorIncomingConfiguration(config), listeners, CountKafkaCdiEvents.noCdiEvents, UnsatisfiedInstance.instance(), 0);
return source;
}
use of io.smallrye.reactive.messaging.kafka.base.SingletonInstance in project smallrye-reactive-messaging by smallrye.
the class ClientTestBase method createSourceSeekToEnd.
public KafkaSource<Integer, String> createSourceSeekToEnd() {
String groupId = UUID.randomUUID().toString();
MapBasedConfig config = createConsumerConfig(groupId).put("topic", topic);
SingletonInstance<KafkaConsumerRebalanceListener> listeners = new SingletonInstance<>(groupId, getKafkaConsumerRebalanceListenerAwaitingAssignationAndSeekToEnd());
source = new KafkaSource<>(vertx, groupId, new KafkaConnectorIncomingConfiguration(config), listeners, CountKafkaCdiEvents.noCdiEvents, UnsatisfiedInstance.instance(), 0);
return source;
}
use of io.smallrye.reactive.messaging.kafka.base.SingletonInstance in project smallrye-reactive-messaging by smallrye.
the class ClientTestBase method createSourceSeekToBeginning.
public KafkaSource<Integer, String> createSourceSeekToBeginning() {
String groupId = UUID.randomUUID().toString();
MapBasedConfig config = createConsumerConfig(groupId).put("topic", topic);
SingletonInstance<KafkaConsumerRebalanceListener> listeners = new SingletonInstance<>(groupId, getKafkaConsumerRebalanceListenerAwaitingAssignationAndSeekToBeginning());
source = new KafkaSource<>(vertx, groupId, new KafkaConnectorIncomingConfiguration(config), listeners, CountKafkaCdiEvents.noCdiEvents, UnsatisfiedInstance.instance(), 0);
return source;
}
Aggregations