CloudEvents Avro Compact

Javadocs

This module provides the Avro Compact EventFormat implementation.

Setup

For Maven based projects, use the following dependency:

<dependency>
    <groupId>io.cloudevents</groupId>
    <artifactId>cloudevents-avro-compact</artifactId>
    <version>x.y.z</version>
</dependency>

No further configuration is required is use the module.

Using the Avro Compact Event Format

Event serialization

import io.cloudevents.CloudEvent;
import io.cloudevents.core.format.EventFormatProvider;
import io.cloudevents.core.builder.CloudEventBuilder;
import io.cloudevents.avro.avro.compact.AvroCompactFormat;

CloudEvent event = CloudEventBuilder.v1()
    .withId("hello")
    .withType("example.vertx")
    .withSource(URI.create("http://localhost"))
    .build();

byte[] serialized = EventFormatProvider
    .getInstance()
    .resolveFormat(AvroCompactFormat.CONTENT_TYPE)
    .serialize(event);

The EventFormatProvider will automatically resolve the format using the ServiceLoader APIs.