@ParametersAreNonnullByDefault public final class JsonEventGenerator extends Object
builder()
.
It provides:
- initialization of default values
- meta.dt as the kafka ingestion time with the provided clock
- meta.stream
- dt as a yet optional event time provided via a param
- $schema as the schema that can validate the generated event
- verification of schema vs stream
- validation of the event against its schemaModifier and Type | Class and Description |
---|---|
static class |
JsonEventGenerator.Builder |
static interface |
JsonEventGenerator.EventNormalizer
A component that applies various normalization and verification steps to the events it receives.
|
Modifier and Type | Field and Description |
---|---|
static String |
EVENT_TIME_FIELD |
static String |
META_FIELD |
static String |
META_ID_FIELD |
static String |
META_INGESTION_TIME_FIELD |
static String |
META_STREAM_FIELD |
static String |
SCHEMA_FIELD |
Modifier and Type | Method and Description |
---|---|
static JsonEventGenerator.Builder |
builder() |
JsonEventGenerator.EventNormalizer |
createEventStreamEventGenerator(String streamName,
String schemaUri)
Create a validating event generator.
|
JsonEventGenerator.EventNormalizer |
createNonValidatingEventStreamEventGenerator(String streamName,
String schemaUri)
Create a non-validating event generator.
|
com.fasterxml.jackson.databind.node.ObjectNode |
generateEvent(String streamName,
String schemaUri,
Consumer<com.fasterxml.jackson.databind.node.ObjectNode> eventData,
Instant eventTime)
Generates an json event calling the supplier eventData.
|
com.fasterxml.jackson.databind.node.ObjectNode |
generateEvent(String streamName,
String schemaUri,
Consumer<com.fasterxml.jackson.databind.node.ObjectNode> eventData,
Instant eventTime,
boolean validate)
Generates a json event calling the supplier eventData.
|
com.fasterxml.jackson.databind.ObjectMapper |
getJsonMapper() |
byte[] |
serializeAsBytes(com.fasterxml.jackson.databind.node.ObjectNode root)
Helper method to serialize the event as bytes.
|
public static final String SCHEMA_FIELD
public static final String EVENT_TIME_FIELD
public static final String META_FIELD
public static final String META_STREAM_FIELD
public static final String META_INGESTION_TIME_FIELD
public static final String META_ID_FIELD
public com.fasterxml.jackson.databind.node.ObjectNode generateEvent(String streamName, String schemaUri, Consumer<com.fasterxml.jackson.databind.node.ObjectNode> eventData, @Nullable Instant eventTime)
streamName
- the stream this event will be pushed toschemaUri
- the schema this event is build againsteventData
- consumer receiving an empty ObjectNode to attach data toeventTime
- the optional eventTime to be set to the dt field (might become mandatory)IllegalArgumentException
- if the schema does not match what is expected from the stream configurationIllegalArgumentException
- if the schema cannot be found/loadedIllegalArgumentException
- if the event is not valid against the provided schemapublic com.fasterxml.jackson.databind.node.ObjectNode generateEvent(String streamName, String schemaUri, Consumer<com.fasterxml.jackson.databind.node.ObjectNode> eventData, @Nullable Instant eventTime, boolean validate)
streamName
- the stream this event will be pushed toschemaUri
- the schema this event is build againsteventData
- consumer receiving an empty ObjectNode to attach data toeventTime
- the optional eventTime to be set to the dt field (might become mandatory)validate
- true to validate the event against its schemaIllegalArgumentException
- if the schema does not match what is expected from the stream configurationIllegalArgumentException
- if the schema cannot be found/loadedIllegalArgumentException
- if the event is not valid against the provided schemapublic JsonEventGenerator.EventNormalizer createEventStreamEventGenerator(String streamName, String schemaUri)
public JsonEventGenerator.EventNormalizer createNonValidatingEventStreamEventGenerator(String streamName, String schemaUri)
public byte[] serializeAsBytes(com.fasterxml.jackson.databind.node.ObjectNode root) throws IOException
IOException
public static JsonEventGenerator.Builder builder()
public com.fasterxml.jackson.databind.ObjectMapper getJsonMapper()
Copyright © 2025. All rights reserved.