sdk-java icon indicating copy to clipboard operation
sdk-java copied to clipboard

Micronaut module

Open untereiner opened this issue 3 years ago • 3 comments

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 ?

untereiner avatar Jan 17 '22 16:01 untereiner

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.

lszymik avatar Feb 28 '22 11:02 lszymik

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?

pierDipi avatar Apr 01 '22 13:04 pierDipi

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

BramMeerten avatar Jul 18 '22 14:07 BramMeerten