org.axonframework.springmessaging.adapter
Class EventListeningMessageChannelAdapter

java.lang.Object
  extended by org.axonframework.springmessaging.adapter.EventListeningMessageChannelAdapter
All Implemented Interfaces:
EventListener, org.springframework.beans.factory.InitializingBean

public class EventListeningMessageChannelAdapter
extends Object
implements EventListener, 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 Summary
EventListeningMessageChannelAdapter(EventBus eventBus, org.springframework.messaging.MessageChannel channel)
          Initialize an adapter to forward messages from the given eventBus to the given channel.
EventListeningMessageChannelAdapter(EventBus eventBus, org.springframework.messaging.MessageChannel channel, EventFilter filter)
          Initialize an adapter to forward messages from the given eventBus to the given channel.
 
Method Summary
 void afterPropertiesSet()
          Subscribes this event listener to the event bus.
 void handle(EventMessage event)
          If allows by the filter, wraps the given event in a GenericMessage ands sends it to the configured MessageChannel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventListeningMessageChannelAdapter

public EventListeningMessageChannelAdapter(EventBus eventBus,
                                           org.springframework.messaging.MessageChannel channel)
Initialize an adapter to forward messages from the given eventBus to the given channel. Messages are not filtered; all messages are forwarded to the MessageChannel

Parameters:
eventBus - The event bus to subscribe to.
channel - The channel to send event messages to.

EventListeningMessageChannelAdapter

public EventListeningMessageChannelAdapter(EventBus eventBus,
                                           org.springframework.messaging.MessageChannel channel,
                                           EventFilter filter)
Initialize an adapter to forward messages from the given eventBus to the given channel. Messages are filtered using the given filter

Parameters:
eventBus - The event bus to subscribe to.
channel - The channel to send event messages to.
filter - The filter that indicates which messages to forward.
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
Subscribes this event listener to the event bus.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

handle

public void handle(EventMessage event)
If allows by the filter, wraps the given event in a GenericMessage ands sends it to the configured MessageChannel.

Specified by:
handle in interface EventListener
Parameters:
event - the event to handle


Copyright © 2010-2016. All Rights Reserved.