|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.eventhandling.AbstractCluster
public abstract class AbstractCluster
Abstract Cluster
implementation that keeps track of Cluster members (EventListeners
).
This implementation is thread-safe. The getMembers()
method returns a read-only runtime view of the members
in the cluster.
Constructor Summary | |
---|---|
protected |
AbstractCluster(String name)
Initializes the cluster with given name . |
protected |
AbstractCluster(String name,
Comparator<EventListener> comparator)
Initializes the cluster with given name , using given comparator to order the listeners
in the cluster. |
Method Summary | |
---|---|
protected abstract void |
doPublish(List<EventMessage> events,
Set<EventListener> eventListeners,
MultiplexingEventProcessingMonitor eventProcessingMonitor)
Publish the given list of events to the given set of eventListeners , and notify the
given eventProcessingMonitor after completion. |
Set<EventListener> |
getMembers()
Returns a read-only view on the members in the cluster. |
ClusterMetaData |
getMetaData()
Returns the MetaData of this Cluster. |
String |
getName()
Returns the name of this cluster. |
void |
publish(EventMessage... events)
Publishes the given Events to the members of this cluster. |
void |
subscribe(EventListener eventListener)
Subscribe the given eventListener to this cluster. |
void |
subscribeEventProcessingMonitor(EventProcessingMonitor monitor)
Subscribes the given monitor . |
void |
unsubscribe(EventListener eventListener)
Unsubscribes the given eventListener from this cluster. |
void |
unsubscribeEventProcessingMonitor(EventProcessingMonitor monitor)
Unsubscribed the given monitor . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected AbstractCluster(String name)
name
. The order in which listeners are organized in the cluster
is undefined.
name
- The name of this clusterprotected AbstractCluster(String name, Comparator<EventListener> comparator)
name
, using given comparator
to order the listeners
in the cluster. The order of invocation of the members in this cluster is according the order provided by the
comparator.
name
- The name of this clustercomparator
- The comparator providing the ordering of the Event ListenersMethod Detail |
---|
public void publish(EventMessage... events)
Cluster
EventListeners
are
discouraged to throw exceptions, it is possible that they are propagated through this method invocation. In that
case, no guarantees can be given about the delivery of Events at all Cluster members.
publish
in interface Cluster
events
- The Events to publish in the clusterprotected abstract void doPublish(List<EventMessage> events, Set<EventListener> eventListeners, MultiplexingEventProcessingMonitor eventProcessingMonitor)
events
to the given set of eventListeners
, and notify the
given eventProcessingMonitor
after completion. The given set of eventListeners
is a
live view on the memberships of the cluster. Any subscription changes are immediately visible in this set.
Iterators created on the set iterate over an immutable view reflecting the state at the moment the iterator was
created.
When this method is invoked as part of a Unit of Work (see
CurrentUnitOfWork.isStarted()
), the monitor invocation should be postponed
until the Unit of Work is committed or rolled back, to ensure any transactions are properly propagated when the
monitor is invoked.
It is the implementation's responsibility to ensure that –eventually– the each of the given
events
is provided to the eventProcessingMonitor
, either to the EventProcessingMonitor.onEventProcessingCompleted(java.util.List)
or the EventProcessingMonitor.onEventProcessingFailed(java.util.List, Throwable)
method.
events
- The events to publisheventListeners
- The event listeners subscribed at the moment the event arrivedeventProcessingMonitor
- The monitor to notify after completion.public String getName()
Cluster
getName
in interface Cluster
public void subscribe(EventListener eventListener)
Cluster
eventListener
to this cluster. If the listener is already subscribed, nothing
happens.
While the Event Listeners is subscribed, it will receive all messages published to the cluster.
subscribe
in interface Cluster
eventListener
- the Event Listener instance to subscribepublic void unsubscribe(EventListener eventListener)
Cluster
eventListener
from this cluster. If the listener is already unsubscribed, or was
never subscribed, nothing happens.
unsubscribe
in interface Cluster
eventListener
- the Event Listener instance to unsubscribepublic ClusterMetaData getMetaData()
Cluster
getMetaData
in interface Cluster
public Set<EventListener> getMembers()
Iterator.remove()
method to be
invoked.
getMembers
in interface Cluster
public void subscribeEventProcessingMonitor(EventProcessingMonitor monitor)
EventProcessingMonitorSupport
monitor
. If the monitor is already subscribed, nothing happens.
subscribeEventProcessingMonitor
in interface EventProcessingMonitorSupport
monitor
- The monitor to subscribepublic void unsubscribeEventProcessingMonitor(EventProcessingMonitor monitor)
EventProcessingMonitorSupport
monitor
. If the monitor was not subscribed, or was already unsubscribed,
nothing happens.
unsubscribeEventProcessingMonitor
in interface EventProcessingMonitorSupport
monitor
- The monitor to unsubscribe
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |