Class EventTransformerChain
- All Implemented Interfaces:
DescribableComponent
EventTransformation instances that transforms events at read time.
Events that match no transformation pass through unchanged; an event a transformation drops is removed. Use
EventTransformerChain.Builder to construct and register transformations.
An exact identity match always takes precedence over a predicate match, independent of registration order; a
predicate from is consulted only when no exact match applies, and among predicates the first registered
match wins.
The chain is a thin read-time engine composing two read-models derived from the registered transformations: a
TransformationIndex answering which transformation applies to an event, and a CriteriaWidener
broadening read criteria so a type-filtering read also fetches the source types the chain transforms.
- Since:
- 5.2.0
- Author:
- Laura Devriendt
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault safety bound on per-event iteration. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Start building a new chain.voiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.transform(MessageStream<? extends EventMessage> stream, @Nullable ProcessingContext context, MessageConverter converter, MessageTypeResolver messageTypeResolver) Transforms every event in the given stream by applying the chain at read time.widen(EventCriteria criteria) Widens the given readEventCriteriaso a type-filtering read still returns every event this chain can transform into one of the queried types.
-
Field Details
-
DEFAULT_MAX_ITERATIONS_PER_EVENT
public static final int DEFAULT_MAX_ITERATIONS_PER_EVENTDefault safety bound on per-event iteration. Covers any reasonable migration chain (most chains are 1-5 hops); deep-history domains can override viaEventTransformerChain.Builder.maxIterationsPerEvent(int).- See Also:
-
-
Method Details
-
transform
public MessageStream<EventMessage> transform(MessageStream<? extends EventMessage> stream, @Nullable ProcessingContext context, MessageConverter converter, MessageTypeResolver messageTypeResolver) Transforms every event in the given stream by applying the chain at read time. Events matching no transformation pass through unchanged; an event a transformation drops is removed, and surviving events keep their stream position.- Parameters:
stream- the input stream of eventscontext- the active processing context, ornullwhen the read path supplies noneconverter- converts a stored payload to a transformation's declared input typemessageTypeResolver- resolves a mapper output's type to verify it against the declaredto- Returns:
- the transformed stream
-
widen
Widens the given readEventCriteriaso a type-filtering read still returns every event this chain can transform into one of the queried types. Returns the same instance when nothing can be widened.- Parameters:
criteria- the read-time criteria to widen- Returns:
- the widened criteria, or the same instance when nothing is broadened
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.Best Practices: As a general rule, all relevant fields of a
DescribableComponentimplementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing thedescribeTomethod, who should focus on providing information that is useful for understanding the component's configuration and state.Example implementation:
public void describeTo(ComponentDescriptor descriptor) { descriptor.describeProperty("name", this.name); descriptor.describeProperty("enabled", this.enabled); descriptor.describeProperty("configuration", this.configuration); // A nested component descriptor.describeProperty("handlers", this.eventHandlers); // A collection }- Specified by:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-
builder
Start building a new chain. UseEventTransformerChain.Builder.register(EventTransformation)to add transformations and, optionally,EventTransformerChain.Builder.maxIterationsPerEvent(int)to adjust the per-event iteration safety bound (defaultDEFAULT_MAX_ITERATIONS_PER_EVENT).- Returns:
- a fresh
EventTransformerChain.Builder
-