Java SDK for CloudEvents
Go to file
Fabio José 7df1d1536d Update vesion and dep
Set version to 0.3.0

Set jee dep to 8 due the error java.lang.NoSuchMethodError: javax.validation.BootstrapConfiguration.getClockProviderClassName()Ljava/lang/String;

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 15:33:02 -03:00
api Changes for wire remaning 2019-09-02 22:01:00 -03:00
cdi Update vesion and dep 2019-09-03 15:33:02 -03:00
http/vertx
kafka Kafka Binding 2019-09-02 22:11:46 -03:00
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md fix changelog anchor 2019-08-26 21:43:54 -03:00
pom.xml

README.md

Java SDK for CloudEvents API

Build Status License Maven Central Javadocs

A Java API for the CloudEvents specification

Checkout the changelog

Motivation

The CloudEvents specification is a 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.2 and it describes a simple event format, which was demonstrated at KubeCon 2018 using different Serverless platforms, such as Apache Openwhisk.

Java API

For Maven based projects, use the following to configure the CloudEvents Java SDK:

<dependency>
    <groupId>io.cloudevents</groupId>
    <artifactId>cloudevents-api</artifactId>
    <version>0.2.2</version>
</dependency>

Application developers can now create strongly-typed CloudEvents, such as:

import io.cloudevents.v02.CloudEventBuilder;
import io.cloudevents.v02.CloudEvent;
import io.cloudevents.v02.ExtensionFormat;
import io.cloudevents.json.Json;
import io.cloudevents.extensions.DistributedTracingExtension;

// given
final String eventId = UUID.randomUUID().toString();
final URI src = URI.create("/trigger");
final String eventType = "My.Cloud.Event.Type";
final MyCustomEvent payload = ...

// add trace extension usin the in-memory format
final DistributedTracingExtension dt = new DistributedTracingExtension();
dt.setTraceparent("00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01");
dt.setTracestate("rojo=00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01");

final ExtensionFormat tracing = new DistributedTracingExtension.InMemory(dt);

// passing in the given attributes
final CloudEvent<MyCustomEvent> cloudEvent = new CloudEventBuilder<MyCustomEvent>()
    .withType(eventType)
    .withId(eventId)
    .withSource(src)
    .withData(payload)
    .withExtension(tracing)
    .build();

// marshalling as json
final String json = Json.encode(cloudEvent);

Possible Integrations

The API is kept simple, for allowing a wide range of possible integrations: