Interface EventExternalizationConfiguration
- All Known Implementing Classes:
DefaultEventExternalizationConfiguration
public interface EventExternalizationConfiguration
Configuration for externalizing application events to messaging infrastructure.
- Since:
- 1.1
- Author:
- Oliver Drotbohm
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classAPI to define the event routing.static classAPI to define which events are supposed to be selected for externalization. -
Method Summary
Modifier and TypeMethodDescriptionAPredicateto select all events annotated as to be externalized.static Function<Object,Optional<RoutingTarget>> byApplicationLocalName(Collection<String> packages) Creates a new routing that uses the application-local type name as targetReturns aFunctionthat looks up the target from the supported externalization annotations.static Function<Object,RoutingTarget> Returns aFunctionthat looks up the target from the fully-qualified type name of the event's type.Creates a defaultDefaultEventExternalizationConfigurationwith the following characteristics: Only events that reside in any of the given packages and that are annotated with any supportedExternalizedannotation will be considered. Routing information is discovered from the {code Externalized} annotation and, if missing, will default to the application-local name of the event type.defaults(Collection<String> packages) Creates a defaultDefaultEventExternalizationConfigurationwith the following characteristics: Only events that reside in any of the given packages and that are annotated with any supportedExternalizedannotation will be considered. Routing information is discovered from the {code Externalized} annotation and, if missing, will default to the application-local name of the event type.determineTarget(Object event) Determines theRoutingTargetfor the given event based on the current configuration.disabled()Disables event externalization by not matching any events at all.Creates a newEventExternalizationConfiguration.Selectorto define which events to externalize.getHeadersFor(Object event) Returns the headers to be attached to the message sent out for the given event.Map the event to be externalized before publishing it.booleanWhether the configuration supports the given event.
-
Method Details
-
defaults
Creates a defaultDefaultEventExternalizationConfigurationwith the following characteristics:- Only events that reside in any of the given packages and that are annotated with any supported
Externalizedannotation will be considered. - Routing information is discovered from the {code Externalized} annotation and, if missing, will default to the
application-local name of the event type. In other words, an event type
com.acme.myapp.mymodule.MyEventwill result in a routemymodule.MyEvent.
- Parameters:
packages- must not be null or empty.- Returns:
- will never be null.
- See Also:
- Only events that reside in any of the given packages and that are annotated with any supported
-
defaults
Creates a defaultDefaultEventExternalizationConfigurationwith the following characteristics:- Only events that reside in any of the given packages and that are annotated with any supported
Externalizedannotation will be considered. - Routing information is discovered from the {code Externalized} annotation and, if missing, will default to the
application-local name of the event type. In other words, an event type
com.acme.myapp.mymodule.MyEventwill result in a routemymodule.MyEvent.
- Parameters:
packages- must not be null or empty.- Returns:
- will never be null.
- Since:
- 1.3
- See Also:
- Only events that reside in any of the given packages and that are annotated with any supported
-
externalizing
Creates a newEventExternalizationConfiguration.Selectorto define which events to externalize.- Returns:
- will never be null.
-
disabled
Disables event externalization by not matching any events at all.- Returns:
- will never be null.
-
annotatedAsExternalized
APredicateto select all events annotated as to be externalized. The currently supported annotations are:- Spring Modulith's
Externalized - jMolecules
Externalized(if present on the classpath)
- Returns:
- will never be null.
- Spring Modulith's
-
byApplicationLocalName
Creates a new routing that uses the application-local type name as target- Parameters:
packages- must not be null.- Returns:
- will never be null.
-
byExternalizedAnnotations
Returns aFunctionthat looks up the target from the supported externalization annotations. The currently supported annotations are:- Spring Modulith's
Externalized - jMolecules
Externalized(if present on the classpath)
- Returns:
- will never be null.
- Spring Modulith's
-
byFullyQualifiedTypeName
Returns aFunctionthat looks up the target from the fully-qualified type name of the event's type.- Returns:
- will never be null.
-
supports
Whether the configuration supports the given event. In other words, whether the given event is supposed to be externalized in the first place.- Parameters:
event- must not be null.- Returns:
- whether to externalize the given event.
-
map
Map the event to be externalized before publishing it.- Parameters:
event- must not be null.- Returns:
- the mapped event.
-
determineTarget
Determines theRoutingTargetfor the given event based on the current configuration.- Parameters:
event- must not be null.- Returns:
- will never be null.
-
getHeadersFor
Returns the headers to be attached to the message sent out for the given event.- Parameters:
event- must not be null.- Returns:
- will never be null.
- Since:
- 1.3
-