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
Modifier and TypeInterfaceDescriptionstatic class
API to define the event routing.static class
API to define which events are supposed to be selected for externalization. -
Method Summary
Modifier and TypeMethodDescriptionAPredicate
to 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 aFunction
that looks up the target from the supported externalization annotations.static Function<Object,
RoutingTarget> Returns aFunction
that looks up the target from the fully-qualified type name of the event's type.Creates a defaultDefaultEventExternalizationConfiguration
with the following characteristics: Only events that reside in any of the given packages and that are annotated with any supportedExternalized
annotation 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 defaultDefaultEventExternalizationConfiguration
with the following characteristics: Only events that reside in any of the given packages and that are annotated with any supportedExternalized
annotation 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 theRoutingTarget
for the given event based on the current configuration.disabled()
Disables event externalization by not matching any events at all.Creates a newEventExternalizationConfiguration.Selector
to 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.boolean
Whether the configuration supports the given event.
-
Method Details
-
defaults
Creates a defaultDefaultEventExternalizationConfiguration
with the following characteristics:- Only events that reside in any of the given packages and that are annotated with any supported
Externalized
annotation 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.MyEvent
will 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 defaultDefaultEventExternalizationConfiguration
with the following characteristics:- Only events that reside in any of the given packages and that are annotated with any supported
Externalized
annotation 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.MyEvent
will 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.Selector
to 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
APredicate
to 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 aFunction
that 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 aFunction
that 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 theRoutingTarget
for 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
-