Search in sources :

Example 26 with KafkaMapBasedConfig

use of io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class HealthCheckTest method testHealthOfApplicationWithChannelUsingTopicVerification.

@Test
public void testHealthOfApplicationWithChannelUsingTopicVerification() {
    KafkaMapBasedConfig config = getKafkaSourceConfig(topic).put("health-readiness-topic-verification", true);
    LazyConsumingBean bean = runApplication(config, LazyConsumingBean.class);
    companion.produceIntegers().usingGenerator(i -> new ProducerRecord<>(topic, "key", i), 10);
    await().until(this::isStarted);
    await().until(this::isReady);
    await().until(this::isAlive);
    // before subscription to channel
    Multi<Integer> channel = bean.getChannel();
    channel.select().first(10).collect().asList().await().atMost(Duration.ofSeconds(10));
    // after subscription to channel
    HealthReport startup = getHealth().getStartup();
    HealthReport liveness = getHealth().getLiveness();
    HealthReport readiness = getHealth().getReadiness();
    assertThat(startup.isOk()).isTrue();
    assertThat(liveness.isOk()).isTrue();
    assertThat(readiness.isOk()).isTrue();
    assertThat(startup.getChannels()).hasSize(1);
    assertThat(liveness.getChannels()).hasSize(1);
    assertThat(readiness.getChannels()).hasSize(1);
}
Also used : HealthReport(io.smallrye.reactive.messaging.health.HealthReport) KafkaMapBasedConfig(io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 27 with KafkaMapBasedConfig

use of io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class BatchFailureHandlerTest method getIgnoreConfig.

private KafkaMapBasedConfig getIgnoreConfig(String topic) {
    KafkaMapBasedConfig config = kafkaConfig("mp.messaging.incoming.kafka");
    config.put("topic", topic);
    config.put("group.id", topic + "-group");
    config.put("value.deserializer", IntegerDeserializer.class.getName());
    config.put("enable.auto.commit", "false");
    config.put("auto.offset.reset", "earliest");
    config.put("failure-strategy", "ignore");
    config.put("batch", true);
    config.put("max.poll.records", 3);
    return config;
}
Also used : IntegerDeserializer(org.apache.kafka.common.serialization.IntegerDeserializer) KafkaMapBasedConfig(io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig)

Example 28 with KafkaMapBasedConfig

use of io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class BatchFailureHandlerTest method getFailConfig.

private KafkaMapBasedConfig getFailConfig(String topic) {
    KafkaMapBasedConfig config = kafkaConfig("mp.messaging.incoming.kafka");
    config.put("group.id", topic + "-group");
    config.put("topic", topic);
    config.put("value.deserializer", IntegerDeserializer.class.getName());
    config.put("enable.auto.commit", "false");
    config.put("auto.offset.reset", "earliest");
    config.put("failure-strategy", "fail");
    config.put("batch", true);
    config.put("max.poll.records", 3);
    return config;
}
Also used : IntegerDeserializer(org.apache.kafka.common.serialization.IntegerDeserializer) KafkaMapBasedConfig(io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig)

Example 29 with KafkaMapBasedConfig

use of io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class BatchFailureHandlerTest method getDeadLetterQueueWithCustomConfig.

private KafkaMapBasedConfig getDeadLetterQueueWithCustomConfig(String topic, String dq) {
    KafkaMapBasedConfig config = kafkaConfig("mp.messaging.incoming.kafka");
    config.put("topic", topic);
    config.put("group.id", topic + "-group");
    config.put("value.deserializer", IntegerDeserializer.class.getName());
    config.put("enable.auto.commit", "false");
    config.put("auto.offset.reset", "earliest");
    config.put("failure-strategy", "dead-letter-queue");
    config.put("dead-letter-queue.topic", dq);
    config.put("dead-letter-queue.key.serializer", IntegerSerializer.class.getName());
    config.put("dead-letter-queue.value.serializer", IntegerSerializer.class.getName());
    config.put("batch", true);
    config.put("max.poll.records", 3);
    return config;
}
Also used : IntegerDeserializer(org.apache.kafka.common.serialization.IntegerDeserializer) IntegerSerializer(org.apache.kafka.common.serialization.IntegerSerializer) KafkaMapBasedConfig(io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig)

Example 30 with KafkaMapBasedConfig

use of io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class KafkaFailureHandlerTest method getDeadLetterQueueWithCustomConfig.

private KafkaMapBasedConfig getDeadLetterQueueWithCustomConfig(String topic, String dq) {
    KafkaMapBasedConfig config = kafkaConfig("mp.messaging.incoming.kafka");
    config.put("group.id", UUID.randomUUID().toString());
    config.put("topic", topic);
    config.put("value.deserializer", IntegerDeserializer.class.getName());
    config.put("enable.auto.commit", "false");
    config.put("auto.offset.reset", "earliest");
    config.put("failure-strategy", "dead-letter-queue");
    config.put("dead-letter-queue.topic", dq);
    config.put("dead-letter-queue.key.serializer", IntegerSerializer.class.getName());
    config.put("dead-letter-queue.value.serializer", IntegerSerializer.class.getName());
    return config;
}
Also used : IntegerDeserializer(org.apache.kafka.common.serialization.IntegerDeserializer) IntegerSerializer(org.apache.kafka.common.serialization.IntegerSerializer) KafkaMapBasedConfig(io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig)

Aggregations

KafkaMapBasedConfig (io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig)86 Test (org.junit.jupiter.api.Test)56 Message (org.eclipse.microprofile.reactive.messaging.Message)34 RecordHeader (org.apache.kafka.common.header.internals.RecordHeader)30 StringSerializer (org.apache.kafka.common.serialization.StringSerializer)25 StringDeserializer (org.apache.kafka.common.serialization.StringDeserializer)22 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)20 JsonObject (io.vertx.core.json.JsonObject)19 ArrayList (java.util.ArrayList)18 KafkaConnectorIncomingConfiguration (io.smallrye.reactive.messaging.kafka.KafkaConnectorIncomingConfiguration)17 KafkaConnectorOutgoingConfiguration (io.smallrye.reactive.messaging.kafka.KafkaConnectorOutgoingConfiguration)17 KafkaSink (io.smallrye.reactive.messaging.kafka.impl.KafkaSink)17 IncomingKafkaCloudEventMetadata (io.smallrye.reactive.messaging.kafka.IncomingKafkaCloudEventMetadata)14 IntegerDeserializer (org.apache.kafka.common.serialization.IntegerDeserializer)14 IntegerSerializer (org.apache.kafka.common.serialization.IntegerSerializer)13 JsonObjectDeserializer (io.vertx.kafka.client.serialization.JsonObjectDeserializer)5 Header (org.apache.kafka.common.header.Header)5 HealthReport (io.smallrye.reactive.messaging.health.HealthReport)4 KafkaCompanionTestBase (io.smallrye.reactive.messaging.kafka.base.KafkaCompanionTestBase)3 List (java.util.List)3