Class OutboundEventMessageChannelAdapter

java.lang.Object
org.axonframework.extension.spring.messaging.OutboundEventMessageChannelAdapter
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean

public class OutboundEventMessageChannelAdapter extends Object implements org.springframework.beans.factory.InitializingBean
Adapter class that sends Events from an event bus to a Spring Messaging Message Channel. All events are wrapped in GenericMessage instances. The adapter automatically subscribes itself to the provided EventBus.

Optionally, this adapter can be configured with a filter, which can block or accept messages based on their type.

Since:
2.3.1
Author:
Allard Buijze
  • Constructor Details

    • OutboundEventMessageChannelAdapter

      public OutboundEventMessageChannelAdapter(@Nonnull SubscribableEventSource eventSource, @Nonnull org.springframework.messaging.MessageChannel channel)
      Initialize an adapter to forward messages from the given eventSource to the given channel. Messages are not filtered; all messages are forwarded to the MessageChannel
      Parameters:
      eventSource - The event bus to subscribe to.
      channel - The channel to send event messages to.
    • OutboundEventMessageChannelAdapter

      public OutboundEventMessageChannelAdapter(@Nonnull SubscribableEventSource eventSource, @Nonnull org.springframework.messaging.MessageChannel channel, Predicate<? super EventMessage> filter)
      Initialize an adapter to forward messages from the given eventSource to the given channel. Messages are filtered using the given filter.
      Parameters:
      eventSource - The source of messages to subscribe to.
      channel - The channel to send event messages to.
      filter - The filter that indicates which messages to forward.
    • OutboundEventMessageChannelAdapter

      public OutboundEventMessageChannelAdapter(@Nonnull SubscribableEventSource eventSource, @Nonnull org.springframework.messaging.MessageChannel channel, Predicate<? super EventMessage> filter, @Nonnull EventMessageConverter eventMessageConverter)
      Initialize an adapter to forward messages from the given eventSource to the given channel. Messages are filtered using the given filter.
      Parameters:
      eventSource - The source of messages to subscribe to.
      channel - The channel to send event messages to.
      filter - The filter that indicates which messages to forward.
      eventMessageConverter - The converter to use to convert event message into Spring message
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet()
      Subscribes this event listener to the event bus.
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • handle

      protected void handle(List<? extends EventMessage> events, ProcessingContext context)
      If allows by the filter, wraps the given event in a GenericMessage ands sends it to the configured MessageChannel.
      Parameters:
      events - the events to handle
    • transform

      protected org.springframework.messaging.Message transform(EventMessage event)
      Transforms the given Axon event into a Spring Messaging Message. This method may be overridden to change how this transformation should occur.
      Parameters:
      event - The Axon EventMessage to transform
      Returns:
      The Spring Messaging Message representing the Event Message