Annotation Type EnableEventSource


@Target(TYPE)
@Retention(RUNTIME)
@Documented
@Import(EventSourceBeanRegistrar.class)
@Repeatable(EnableEventSources.class)
@EnableEventSourcing
public @interface EnableEventSource
Enables auto-configuration of event sources.

A Spring bean with type EventSource is registered at the ApplicationContext. The name of the beans can be specified by name().

EventSources are created using a EventSourceBuilder that must be registered in the ApplicationContext. The default builder is configured in SynapseAutoConfiguration and will create instances of DefaultEventSource.

Because the EventSourceBuilder is annotated as ConditionalOnMissingBean, it can be replaced by other implementations by just registering a different bean.

The EventSource.getChannelName() is configured using channelName().

  • Element Details

    • channelName

      java.lang.String channelName
      The name of the message channel.

      Resolving placeholders like "${my.channel.name}" is supported for this property.

      Returns:
      channel name
    • name

      java.lang.String name
      The name of the registered EventSource bean.

      If #name is not set, the name of the bean is derived from the name of the message channel. The name is constructed by tranforming hyphenated variable naming convention, e.g., "my-channel" into the Spring bean naming convention, e.g., "myChannel". After this conversion, the string "EventSource" is appended. A channel named "my-channel" will therefore result in a bean name "myChannelEventSource".

      Returns:
      bean name
      Default:
      ""
    • messageLogReceiverEndpoint

      java.lang.String messageLogReceiverEndpoint
      The name of the MessageLogReceiverEndpoint bean that is used to create the EventSource bean.

      If messageLogReceiverEndpoint is not set, the name of the bean is derived from the name of the message channel. The name is constructed by tranforming hyphenated variable naming convention, e.g., "my-channel" into the Spring bean naming convention, e.g., "myChannel". After this conversion, the string "MessageLogReceiverEndpoint" is appended. A channel named "my-channel" will therefore result in a bean name "myChannelMessageLogReceiverEndpoint".

      The EventSourceBeanRegistrar is responsible for creating the EventSources specified by this annotation. The bean name, either specified or derived from the channelName, will be used by the EventSourceBeanRegistrar as the name of the registered message log bean. If a bean having this name already exists, a BeanCreationException will be thrown during startup.

      Returns:
      bean name of the MessageLogReceiverEndpoint
      Default:
      ""
    • selector

      java.lang.Class<? extends MessageLog> selector
      Selector used to select one of possibly multiple available MessageLogReceiverEndpointFactory instances used to create the MessageLogReceiverEndpoint of the EventSource.

      Example: the KafkaMessageLogReceiverEndpointFactory matches both MessageLog.class and Kafka.class. The following usage of the annotation is selecting the KafkaMessageLogReceiverEndpointFactory using the more specific Kafka selector:

      
       @Configuration
       @EnableEventSource(
            channelName = "some-log",
            selector = Kafka.class)
       class MyExampleConfiguration {
       }
       
      Returns:
      MessageLog selector class
      Default:
      de.otto.synapse.channel.selector.MessageLog.class