org.axonframework.eventhandling
Class ClusteringEventBus

java.lang.Object
  extended by org.axonframework.eventhandling.ClusteringEventBus
All Implemented Interfaces:
EventBus

public class ClusteringEventBus
extends Object
implements EventBus

EventBus implementation that supports clustering of Event Listeners. Clusters are connected using EventBus Terminals, which may either distribute Events locally, or remotely.

The separation of EventListeners in clusters allows for a more flexible method of distribution of Events to their listeners. Some clusters may be connected using a remote distribution mechanism, while other clusters handle their events asynchronously.

Since:
1.2
Author:
Allard Buijze

Constructor Summary
ClusteringEventBus()
          Initializes a ClusteringEventBus with a SimpleEventBusTerminal and a DefaultClusterSelector.
ClusteringEventBus(ClusterSelector clusterSelector)
          Initializes a ClusteringEventBus with the given clusterSelector and a SimpleEventBusTerminal, which dispatches all events to all local clusters synchronously.
ClusteringEventBus(ClusterSelector clusterSelector, EventBusTerminal terminal)
          Initializes a ClusteringEventBus with the given clusterSelector and a terminal.
ClusteringEventBus(EventBusTerminal terminal)
          Initializes a ClusteringEventBus with the given terminal and a DefaultClusterSelector.
 
Method Summary
 void publish(EventMessage... events)
          Publish a collection of events on this bus (one, or multiple).
 void subscribe(EventListener eventListener)
          Subscribe the given eventListener to this bus.
 void unsubscribe(EventListener eventListener)
          Unsubscribe the given eventListener to this bus.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClusteringEventBus

public ClusteringEventBus()
Initializes a ClusteringEventBus with a SimpleEventBusTerminal and a DefaultClusterSelector. This causes dispatching to happen synchronously and places all subscribed event handlers in a single cluster, making its default behavior similar to that of the SimpleEventBus.


ClusteringEventBus

public ClusteringEventBus(EventBusTerminal terminal)
Initializes a ClusteringEventBus with the given terminal and a DefaultClusterSelector. This places all subscribed event handlers in a single cluster. The terminal is responsible for publishing incoming events in this cluster.

Parameters:
terminal - The terminal responsible for dispatching events to the clusters

ClusteringEventBus

public ClusteringEventBus(ClusterSelector clusterSelector)
Initializes a ClusteringEventBus with the given clusterSelector and a SimpleEventBusTerminal, which dispatches all events to all local clusters synchronously.

Parameters:
clusterSelector - The Cluster Selector that chooses the cluster for each of the subscribed event listeners

ClusteringEventBus

public ClusteringEventBus(ClusterSelector clusterSelector,
                          EventBusTerminal terminal)
Initializes a ClusteringEventBus with the given clusterSelector and a terminal.

Parameters:
clusterSelector - The Cluster Selector that chooses the cluster for each of the subscribed event listeners
terminal - The terminal responsible for publishing incoming events to each of the clusters
Method Detail

publish

public void publish(EventMessage... events)
Description copied from interface: EventBus
Publish a collection of events on this bus (one, or multiple). The events will be dispatched to all subscribed listeners.

Implementations may treat the given events as a single batch and distribute the events as such to all subscribed EventListeners.

Specified by:
publish in interface EventBus
Parameters:
events - The collection of events to publish

subscribe

public void subscribe(EventListener eventListener)
Description copied from interface: EventBus
Subscribe the given eventListener to this bus. When subscribed, it will receive all events published to this bus.

If the given eventListener is already subscribed, nothing happens.

Specified by:
subscribe in interface EventBus
Parameters:
eventListener - The event listener to subscribe

unsubscribe

public void unsubscribe(EventListener eventListener)
Description copied from interface: EventBus
Unsubscribe the given eventListener to this bus. When unsubscribed, it will no longer receive events published to this bus.

Specified by:
unsubscribe in interface EventBus
Parameters:
eventListener - The event listener to unsubscribe


Copyright © 2010-2016. All Rights Reserved.