Class ProcessorEventHandlingComponents
- All Implemented Interfaces:
DescribableComponent
EventHandlingComponent instances and processing event messages through
them. Each event handling component is wrapped in a SequencingEventHandlingComponent to ensure proper
sequencing where required.
Key responsibilities include:
- Distributing event messages to the associated
EventHandlingComponentinstances. - Ensuring event handling sequencing policies are respected when applicable.
- Determining support for specific event types across the managed components.
- Since:
- 5.0.0
- Author:
- Mateusz Nowak
-
Constructor Summary
ConstructorsConstructorDescriptionProcessorEventHandlingComponents(List<EventHandlingComponent> components) Constructs aProcessorEventHandlingComponentsinstance by wrapping the provided list ofEventHandlingComponents in SequencingEventHandlingComponent instances for sequential event handling where needed. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.handle(List<? extends EventMessage> events, ProcessingContext context) Processes a batch of events in the processing context.handleReset(ResetContext resetContext, ProcessingContext context) Handles reset for all components that support it.replayStarted(ProcessingContext context) Handles the start of a replay for all components.sequenceIdentifiersFor(EventMessage event, ProcessingContext context) Retrieves a set of sequence identifiers for the given event message and processing context.Retrieves a set of all event names supported by the components comprising this ProcessorEventHandlingComponents instance.booleansupports(QualifiedName eventName) Checks if the specified event name is supported by any of the components.booleanChecks if any component supports reset operations.
-
Constructor Details
-
ProcessorEventHandlingComponents
Constructs aProcessorEventHandlingComponentsinstance by wrapping the provided list ofEventHandlingComponents in SequencingEventHandlingComponent instances for sequential event handling where needed.- Parameters:
components- The list ofEventHandlingComponents to be used for event processing. Must not be null and is transformed into a list ofSequencingEventHandlingComponents if necessary.
-
-
Method Details
-
handle
public MessageStream.Empty<Message> handle(List<? extends EventMessage> events, ProcessingContext context) Processes a batch of events in the processing context.The result of handling is an
empty stream. It's guaranteed that the events with samesequenceIdentifiersFor(EventMessage, ProcessingContext)value are processed by a single component in the order they are received, but the sequencing of event processing is not preserved between different event handling components. This is intentional, as they may have different sequencing policies.- Parameters:
events- The batch of event messages to be processed.context- The processing context in which the event messages are processed.- Returns:
- A stream of messages resulting from the processing of the event messages.
-
supportedEvents
Retrieves a set of all event names supported by the components comprising this ProcessorEventHandlingComponents instance. Each event is referenced through a QualifiedName.- Returns:
- A set of QualifiedName objects representing the supported events.
-
supports
Checks if the specified event name is supported by any of the components.- Parameters:
eventName- The qualified name of the event to be checked. Must not be null.- Returns:
- true if the event name is supported, false otherwise.
-
sequenceIdentifiersFor
Retrieves a set of sequence identifiers for the given event message and processing context. Each identifier represents a sequence property determined by the components within this instance.- Parameters:
event- The event message for which the sequence identifiers are to be determined. Must not be null.context- The processing context in which the sequence identifiers are evaluated. Must not be null.- Returns:
- A set of sequence identifiers associated with the given event and context.
-
handleReset
Handles reset for all components that support it.This method invokes the reset handler on each component that supports reset operations. All handlers must complete successfully for the operation to succeed.
- Parameters:
resetContext- The reset context message.context- The processing context.- Returns:
- A future that completes when all reset handlers have completed.
-
supportsReset
public boolean supportsReset()Checks if any component supports reset operations.- Returns:
trueif at least one component supports reset,falseotherwise.
-
replayStarted
Handles the start of a replay for all components.This method invokes the
ReplayStatusChangedHandlerson each component. All handlers must complete successfully for the operation to succeed.- Parameters:
context- the processing context- Returns:
- a future that completes when all
ReplayStatusChangedHandlershave completed
-
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.
-