Simple CDI libray for the CloudEvents Specification
A more detailed introduction is here
Below is a simple overview!
Adding the jax-rs
or kafka
module to your application integrates, either the /ce
JAX-RS endpoint, or a configurable Kafka consumer for handling CloudEvents from within your application!
Receiving different multi-cloud events, using the CDI API:
public class Monitor {
public void receiveCloudEventFromAWS(@Observes @EventType(name = "aws.s3.object.created") CloudEvent<?> cloudEvent) {
System.out.println("S3 event: " + cloudEvent);
}
public void receiveCloudEventFromAzure(@Observes @EventType(name = "Microsoft.Storage.BlobCreated") CloudEvent<?> cloudEvent) {
System.out.println("Azure event: " + cloudEvent);
}
}
Vanilla CDI support and APIs for CloudEvents
public class EventPublisher {
@Inject
private Event<CloudEvent<MyCustomEvent>> cloudEvent;
public void doAndTrigger() throws Exception {
// do some domain specific stuff...
CloudEvent<MyCustomEvent> event = new CloudEventBuilder<MyCustomEvent>()
.eventType("Cloud.Storage.Item.Created")
.source(new URI("/trigger"))
.eventID(UUID.randomUUID().toString())
.build();
cloudEvent.select(
new EventTypeQualifier("Cloud.Storage.Item.Created"))
.fire(event);
}
}