我有一个来自 HTTP POST 的传入 io.cloudevents.CloudEvent 对象,并且希望使用 Quarkus 使用这种方法将对象按原样中继到 Kafka 主题。有没有办法做到这一点?谢谢。
----RESTResource.java-----
@Inject
@Broadcast
@Channel("mychannel") Emitter<CloudEvent> ceEmitter;
@POST
public CompletionStage<Response> sendEvent(CloudEvent object) {
return CompletableFuture.supplyAsync(() -> {
Set<ConstraintViolation<CloudEvent>> violations = validator.validate(object);
ceEmitter.send(object);
return Response.accepted().build();
});
}
-----KafkaProducer.java-----
@Incoming("mychannel")
@Outgoing("mytopic")
public Message<CloudEvent> generate(CloudEvent ce) {
return Message.of(ce);
}
mp.messaging.outgoing.mytopic.value.serializer=??? mp.messaging.incoming.mytopic.value.deserializer=???