use of io.smallrye.reactive.messaging.kafka.impl.KafkaSink in project smallrye-reactive-messaging by smallrye.
the class KafkaSinkWithLegacyMetadataTest method testSinkUsingInteger.
@SuppressWarnings("unchecked")
@Test
public void testSinkUsingInteger() {
ConsumerTask<String, Integer> consumed = companion.consumeIntegers().fromTopics(topic, 10, Duration.ofSeconds(10));
MapBasedConfig config = getBaseConfig().with("topic", topic).with("value.serializer", IntegerSerializer.class.getName()).with("partition", 0).with("channel-name", "testSinkUsingInteger");
KafkaConnectorOutgoingConfiguration oc = new KafkaConnectorOutgoingConfiguration(config);
sink = new KafkaSink(oc, CountKafkaCdiEvents.noCdiEvents, UnsatisfiedInstance.instance());
Subscriber<? extends Message<?>> subscriber = sink.getSink().build();
Multi.createFrom().range(0, 10).map(Message::of).subscribe((Subscriber<? super Message<Integer>>) subscriber);
assertThat(consumed.awaitCompletion(Duration.ofMinutes(1)).count()).isEqualTo(10);
}
use of io.smallrye.reactive.messaging.kafka.impl.KafkaSink in project smallrye-reactive-messaging by smallrye.
the class KafkaSinkWithLegacyMetadataTest method testSinkUsingIntegerAndChannelName.
@Test
@SuppressWarnings("unchecked")
public void testSinkUsingIntegerAndChannelName() {
ConsumerTask<String, Integer> consumed = companion.consumeIntegers().fromTopics(topic, 10, Duration.ofSeconds(10));
MapBasedConfig config = getBaseConfig().with("channel-name", topic).with("value.serializer", IntegerSerializer.class.getName()).with("partition", 0);
KafkaConnectorOutgoingConfiguration oc = new KafkaConnectorOutgoingConfiguration(config);
sink = new KafkaSink(oc, CountKafkaCdiEvents.noCdiEvents, UnsatisfiedInstance.instance());
Subscriber<? extends Message<?>> subscriber = sink.getSink().build();
Multi.createFrom().range(0, 10).map(Message::of).subscribe((Subscriber<? super Message<Integer>>) subscriber);
assertThat(consumed.awaitCompletion(Duration.ofMinutes(1)).count()).isEqualTo(10);
}
use of io.smallrye.reactive.messaging.kafka.impl.KafkaSink in project smallrye-reactive-messaging by smallrye.
the class KafkaSinkWithLegacyMetadataTest method testSinkUsingString.
@Test
@SuppressWarnings("unchecked")
public void testSinkUsingString() {
ConsumerTask<String, String> consumed = companion.consumeStrings().fromTopics(topic, 10, Duration.ofSeconds(10));
MapBasedConfig config = getBaseConfig().with("topic", topic).with("value.serializer", StringSerializer.class.getName()).with("partition", 0).with("channel-name", "testSinkUsingString");
KafkaConnectorOutgoingConfiguration oc = new KafkaConnectorOutgoingConfiguration(config);
sink = new KafkaSink(oc, CountKafkaCdiEvents.noCdiEvents, UnsatisfiedInstance.instance());
Subscriber<? extends Message<?>> subscriber = sink.getSink().build();
Multi.createFrom().range(0, 10).map(i -> Integer.toString(i)).map(Message::of).subscribe((Subscriber<? super Message<String>>) subscriber);
assertThat(consumed.awaitCompletion(Duration.ofMinutes(1)).count()).isEqualTo(10);
}
use of io.smallrye.reactive.messaging.kafka.impl.KafkaSink in project smallrye-reactive-messaging by smallrye.
the class KafkaSinkTest method testSinkUsingString.
@Test
@SuppressWarnings("unchecked")
public void testSinkUsingString() {
ConsumerTask<String, String> consumed = companion.consumeStrings().fromTopics(topic, 10, Duration.ofSeconds(10));
MapBasedConfig config = getBaseConfig().with("topic", topic).with("value.serializer", StringSerializer.class.getName()).with("partition", 0).with("channel-name", "testSinkUsingString");
KafkaConnectorOutgoingConfiguration oc = new KafkaConnectorOutgoingConfiguration(config);
sink = new KafkaSink(oc, CountKafkaCdiEvents.noCdiEvents, UnsatisfiedInstance.instance());
Subscriber<? extends Message<?>> subscriber = sink.getSink().build();
Multi.createFrom().range(0, 10).map(i -> Integer.toString(i)).map(Message::of).subscribe((Subscriber<? super Message<String>>) subscriber);
assertThat(consumed.awaitCompletion(Duration.ofMinutes(1)).count()).isEqualTo(10);
}
Aggregations