|
||
---|---|---|
api | ||
http/vertx | ||
.gitignore | ||
.travis.yml | ||
LICENSE | ||
README.md | ||
pom.xml |
README.md
Java SDK for CloudEvents API
A Java API for the CloudEvents specification
Motivation
The CloudEvents specification is vendor-neutral specification for defining the format of event data that is being exchanged between different cloud systems. The specification basically defines an abstract envelope for any event data payload, without knowing specific implementation details of the actual underlying event. The current version of the spec is at 0.1
and it describes a simple event format, which was demonstrated at last KubeCon 2018 using different Serverless platforms, such as Apache Openwhisk.
Java API
Based on the specification we started to look at an early implementation of the API for Java. Using the API your backend application can create strongly-typed CloudEvents, such as:
// given
final String eventId = UUID.randomUUID().toString();
final URI src = URI.create("/trigger");
final String eventType = "My.Cloud.Event.Type";
final Map<String, String> payload = ...
// passing in the given attributes
final CloudEvent<Map<String, String>> simpleKeyValueEvent = new CloudEventBuilder()
.eventType(eventType)
.eventID(eventId)
.source(src)
.data(payload)
.build();
Possible Integrations
The idea on the API is to keep the pure API simple, for allowing a wide range of possible integrations
CDI Integration
In Enterprise Java applications, implemented with Jakarta EE or the Eclipse Microprofile, it's trivial to combine this API with CDI. Application developers can now fire a CloudEvent for further processing inside of the application:
cloudEvent.select(
new EventTypeQualifier("My.Cloud.Event.Type"))
.fire(event);
This will basically route the event to an Observer Bean, that is interested in the specific event type:
public void receiveCloudEvent(
@Observes @EventType(name = "My.Cloud.Event.Type") CloudEvent cloudEvent) {
// handle the event
}