use of io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class PerformanceProducerTest method testWithoutBackPressureAndNoWait.
@Test
public void testWithoutBackPressureAndNoWait() {
String topic = UUID.randomUUID().toString();
companion.topics().createAndWait(topic, 10);
ConsumerTask<String, Integer> consumed = companion.consumeIntegers().fromTopics(topic, COUNT, Duration.ofMinutes(TIMEOUT_IN_MINUTES));
KafkaMapBasedConfig config = kafkaConfig("mp.messaging.outgoing.kafka").put("topic", topic).put("max-inflight-messages", 0L).put("waitForWriteCompletion", false).put("value.serializer", IntegerSerializer.class.getName());
GeneratorBean bean = runApplication(config, GeneratorBean.class);
await().until(this::isReady);
await().until(this::isAlive);
long begin = System.currentTimeMillis();
bean.run();
await().atMost(Duration.ofMinutes(TIMEOUT_IN_MINUTES)).until(() -> bean.count() == COUNT);
long end = System.currentTimeMillis();
// Wait until all the messages are read.
consumed.awaitCompletion(Duration.ofMinutes(TIMEOUT_IN_MINUTES));
long duration = end - begin;
System.out.println("Time " + duration + " ms");
double speed = (COUNT * 1.0) / (duration / 1000.0);
System.out.println(speed + " messages/ms");
}
use of io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class ConsumerRecordConverterTest method testBeanUsingConverterWithNullKeyAndValue.
@Test
public void testBeanUsingConverterWithNullKeyAndValue() {
KafkaMapBasedConfig builder = kafkaConfig("mp.messaging.incoming.data");
builder.put("value.deserializer", StringDeserializer.class.getName());
builder.put("auto.offset.reset", "earliest");
builder.put("topic", topic);
addBeans(ConsumerRecordConverter.class, RecordConverter.class);
RecordConverterTest.MyBean bean = runApplication(builder, RecordConverterTest.MyBean.class);
companion.produceStrings().usingGenerator(i -> new ProducerRecord<>(topic, null, null), 10);
await().until(() -> bean.list().size() == 10);
assertThat(bean.list()).hasSize(10).allSatisfy(r -> {
assertThat(r.value()).isNull();
assertThat(r.value()).isNull();
});
}
use of io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class ConsumerRecordsConverterTest method testBeanUsingConverterWithNullKeyAndValue.
@Test
public void testBeanUsingConverterWithNullKeyAndValue() {
KafkaMapBasedConfig builder = kafkaConfig("mp.messaging.incoming.data");
builder.put("value.deserializer", StringDeserializer.class.getName());
builder.put("auto.offset.reset", "earliest");
builder.put("topic", topic);
builder.put("batch", true);
addBeans(ConsumerRecordsConverter.class);
MyBean bean = runApplication(builder, MyBean.class);
companion.produceStrings().usingGenerator(i -> new ProducerRecord<>(topic, null, null), 10);
await().until(() -> bean.list().stream().mapToInt(ConsumerRecords::count).sum() == 10);
List<ConsumerRecord<String, String>> consumerRecords = bean.list().stream().flatMap(r -> StreamSupport.stream(r.records(topic).spliterator(), false)).collect(Collectors.toList());
assertThat(consumerRecords).hasSize(10).allSatisfy(r -> {
assertThat(r.value()).isNull();
assertThat(r.value()).isNull();
});
}
use of io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class RecordConverterTest method testBeanUsingConverter.
@Test
public void testBeanUsingConverter() {
KafkaMapBasedConfig builder = kafkaConfig("mp.messaging.incoming.data");
builder.put("value.deserializer", StringDeserializer.class.getName());
builder.put("auto.offset.reset", "earliest");
builder.put("topic", topic);
addBeans(ConsumerRecordConverter.class, RecordConverter.class);
MyBean bean = runApplication(builder, MyBean.class);
companion.produceStrings().usingGenerator(i -> new ProducerRecord<>(topic, i % 2 == 0 ? "key" : "k", "v-" + i), 10);
await().until(() -> bean.list().size() == 10);
assertThat(bean.list()).hasSize(10).allSatisfy(r -> {
assertThat(r.value()).startsWith("v-");
assertThat(r.key()).startsWith("k");
if (!r.key().equalsIgnoreCase("key")) {
assertThat(r.key()).isEqualTo("k");
}
});
}
use of io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class RecordConverterTest method testBeanUsingConverterWithNullKeyAndValue.
@Test
public void testBeanUsingConverterWithNullKeyAndValue() {
KafkaMapBasedConfig builder = kafkaConfig("mp.messaging.incoming.data");
builder.put("value.deserializer", StringDeserializer.class.getName());
builder.put("auto.offset.reset", "earliest");
builder.put("topic", topic);
addBeans(ConsumerRecordConverter.class, RecordConverter.class);
MyBean bean = runApplication(builder, MyBean.class);
companion.produceStrings().usingGenerator(i -> new ProducerRecord<>(topic, null, null), 10);
await().until(() -> bean.list().size() == 10);
assertThat(bean.list()).hasSize(10).allSatisfy(r -> {
assertThat(r.value()).isNull();
assertThat(r.value()).isNull();
});
}
Aggregations