Java SDK for CloudEvents
Go to file
Fabio José d66adea035 New secring
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-28 10:40:48 -03:00
api Set the version 0.3.0 for release (without snapshot) 2019-09-26 17:06:04 -03:00
cdi Set the version 0.3.0 for release (without snapshot) 2019-09-26 17:06:04 -03:00
http/vertx Set the version 0.3.0 for release (without snapshot) 2019-09-26 17:06:04 -03:00
kafka Set the version 0.3.0 for release (without snapshot) 2019-09-26 17:06:04 -03:00
.gitignore ☁️ CloudEvent Java API 2018-10-06 09:13:59 +02:00
.travis.deploy.sh Enable the full command 2019-09-28 09:30:45 -03:00
.travis.pubring Pubring open at all 2019-09-27 21:47:59 -03:00
.travis.secring.enc New secring 2019-09-28 10:40:48 -03:00
.travis.settings.xml Maven settings for automated release 2019-09-26 17:00:41 -03:00
.travis.yml Remove the gpg1 installation 2019-09-28 10:15:51 -03:00
CHANGELOG.md Preparation for pr, add right version compare links 2019-09-20 12:41:15 -03:00
LICENSE Initial commit 2018-09-20 15:56:37 -04:00
README.md Fix english grammer 2019-09-18 22:28:31 -03:00
pom.xml Remove pinentry mode 2019-09-28 09:39:59 -03:00

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.3.0</version>
</dependency>

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

import io.cloudevents.v02.CloudEventBuilder;
import io.cloudevents.v02.CloudEventImpl;
import io.cloudevents.extensions.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.Format(dt);

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

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

There are other detailed ways of how to use the marshallers and unmarshallers with HTTP transport binding.

Kafka

The support for kafka transport binding is available. Read the documentation and examples of use.

Possible Integrations

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