@ThreadSafe public final class ClusteredChangeBus extends MessageConsumer<ChangeSet> implements ChangeBus
ChangeBus
which can run in a cluster, via ClusteringService
. This bus wraps around another
bus, to which it delegates all "local" processing of events.
It is important that the order of the ChangeSet
instances are maintained across the
cluster, and JGroups will do this for us as long as we push all local changes into the channel and receive all local/remote
changes from the channel.
Constructor and Description |
---|
ClusteredChangeBus(ChangeBus delegate,
ClusteringService clusteringService)
Creates a new clustered repository bus
|
Modifier and Type | Method and Description |
---|---|
void |
consume(ChangeSet changes)
Consumes a payload of the given type.
|
boolean |
hasObservers()
Checks if there are any observers registered with the bus.
|
protected void |
logReceivedOperation(ChangeSet changeSet) |
protected void |
logSendOperation(ChangeSet changeSet) |
void |
notify(ChangeSet changeSet)
Notifies a listener of the given changes.
|
boolean |
register(ChangeSetListener listener)
Register the supplied observer.
|
boolean |
registerInThread(ChangeSetListener listener)
Register the supplied observer which will be always notified in the same thread as the bus instance.
|
void |
shutdown()
Shuts down the change bus, closing and clearing resources created during
ChangeBus.start() |
void |
start()
Starts up the change bus.
|
boolean |
unregister(ChangeSetListener listener)
Unregister the supplied observer.
|
getPayloadType
public ClusteredChangeBus(ChangeBus delegate, ClusteringService clusteringService)
delegate
- the local bus to which changes will be delegatedclusteringService
- the object which will handle sending/receiving information in the cluster.public void consume(ChangeSet changes)
MessageConsumer
consume
in class MessageConsumer<ChangeSet>
changes
- a Serializable
payload.public void start() throws Exception
ChangeBus
public boolean hasObservers()
ChangeBus
hasObservers
in interface ChangeBus
true
if there are any registered observers, false
otherwisepublic void shutdown()
ChangeBus
ChangeBus.start()
public void notify(ChangeSet changeSet)
ChangeSetListener
notify
in interface ChangeSetListener
changeSet
- a non-null
ChangeSet
protected final void logSendOperation(ChangeSet changeSet)
protected final void logReceivedOperation(ChangeSet changeSet)
public boolean register(ChangeSetListener listener)
Observable
register
in interface Observable
listener
- the observer to be added; may be nullpublic boolean registerInThread(ChangeSetListener listener)
ChangeBus
registerInThread
in interface ChangeBus
listener
- the observer to be added; may be nullpublic boolean unregister(ChangeSetListener listener)
Observable
unregister
in interface Observable
listener
- the observer to be removed; may not be nullCopyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.