use of io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class KafkaNackPropagationTest method getDoubleNackConfig.
private KafkaMapBasedConfig getDoubleNackConfig() {
KafkaMapBasedConfig config = kafkaConfig("mp.messaging.outgoing.kafka");
config.put("value.serializer", IntegerSerializer.class.getName());
config.put("topic", "double-topic");
return config;
}
use of io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class PerformanceProducerTest method testDefault.
@Test
public void testDefault() {
String topic = UUID.randomUUID().toString();
companion.topics().createAndWait(topic, 10);
ConsumerTask<String, Integer> records = companion.consumeIntegers().fromTopics(topic, COUNT, Duration.ofMinutes(1));
KafkaMapBasedConfig config = kafkaConfig("mp.messaging.outgoing.kafka").put("topic", topic).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.
records.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 PerformanceProducerTest method testWithoutBackPressureAndIncreaseKafkaRequests.
@Test
public void testWithoutBackPressureAndIncreaseKafkaRequests() {
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("max.in.flight.requests.per.connection", 100).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 PerformanceProducerTest method testWithoutBackPressureAndIdempotence.
@Test
public void testWithoutBackPressureAndIdempotence() throws InterruptedException {
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("enable.idempotence", true).put("acks", "all").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 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");
}
});
}
Aggregations