sdk-java
sdk-java copied to clipboard
Micronaut module
Hi, I am using the Micronaut framework and I have been thinking using CloudEvents between my microservices. Would it be interesting to provide a Micronaut module with the same spirit of the spring boot one to this sdk ?
Hello, I was also trying to use CloudEvents with Micronaut. It is not working out of the box. It will be very valuable to have integration.
Hello, I've never used Micronout, so I'm don't know if I can maintain the integration, however, I'd like to understand more about the integration with Micronout, does anyone of you have something to show? a public proof of concept?
I got it working with a few lines of code using io.cloudevents:cloudevents-http-basic
and io.micronaut:micronaut-http-client
:
@Singleton
public class MyEventPublisher {
@Inject
private HttpClient httpClient;
private final String BROKER_URI = "http://broker-ingress.knative-eventing.svc.cluster.local/my-broker-url";
Mono<void> sendEvent(CloudEvent event) {
var request = HttpRequest.POST(URI.create(BROKER_URI), event);
HttpMessageFactory.createWriter(request::header, request::body).writeBinary(event);
return Mono.from(httpClient.retrieve(request, Void.class));
}
}
Would be nice though to get it working with a Declarative Client