I'm trying to inject a KafkaTemplate
to send a single message. I'm developing a small function that lies outside the reactive approach.
I can only find examples that use @Ingoing
and @Outgoing
from Smallrye but I don't need a KafkaStream
.
I tried with Kafka-CDI but I'm unable to inject the SimpleKafkaProducer
.
Any ideas?
For Clement's answer
It seems the right direction, but executing orders.send("hello");
I receive this error:
(vert.x-eventloop-thread-3) Unhandled exception:java.lang.IllegalStateException: Stream not yet connected
I'm consuming from my topic by command line, Kafka is up and running, if I produce manually I can see the consumed messages.
It seems relative to this sentence by the doc:
To use an Emitter for the stream hello, you need a @Incoming("hello") somewhere in your code (or in your configuration).
I have this code in my class:
@Incoming("orders")
public CompletionStage<Void> consume(KafkaMessage<String, String> msg) {
log.info("Received message (topic: {}, partition: {}) with key {}: {}", msg.getTopic(), msg.getPartition(), msg.getKey(), msg.getPayload());
return msg.ack();
}
Maybe I've forgotten some configurations?