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:
  • Method Details

    • defaults

      Creates a default DefaultEventExternalizationConfiguration 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 route mymodule.MyEvent.
      Parameters:
      packages - must not be null or empty.
      Returns:
      will never be null.
      See Also:
    • defaults

      static EventExternalizationConfiguration.Router defaults(String... packages)
      Creates a default DefaultEventExternalizationConfiguration 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 route mymodule.MyEvent.
      Parameters:
      packages - must not be null or empty.
      Returns:
      will never be null.
      Since:
      1.3
      See Also:
    • externalizing

      Creates a new EventExternalizationConfiguration.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

      static Predicate<Object> annotatedAsExternalized()
      A Predicate 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.
    • byApplicationLocalName

      static Function<Object,Optional<RoutingTarget>> byApplicationLocalName(Collection<String> packages)
      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

      static Function<Object,Optional<RoutingTarget.ParsedRoutingTarget>> byExternalizedAnnotations()
      Returns a Function 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.
    • byFullyQualifiedTypeName

      static Function<Object,RoutingTarget> byFullyQualifiedTypeName()
      Returns a Function that looks up the target from the fully-qualified type name of the event's type.
      Returns:
      will never be null.
    • supports

      boolean supports(Object event)
      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

      Object map(Object event)
      Map the event to be externalized before publishing it.
      Parameters:
      event - must not be null.
      Returns:
      the mapped event.
    • determineTarget

      RoutingTarget determineTarget(Object event)
      Determines the RoutingTarget for the given event based on the current configuration.
      Parameters:
      event - must not be null.
      Returns:
      will never be null.
    • getHeadersFor

      Map<String,Object> getHeadersFor(Object event)
      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
    • serializeExternalization

      boolean serializeExternalization()
      Returns whether the event externalization should be serialized to make sure the broker sees the events in the order they were published in the application. By default, this is not guaranteed as multiple threads might trigger events and the externalization of one event might overtake the one of another.
      Since:
      2.0