public class OfBizMessageHandlerService extends Object implements MessageHandlerService
ClusterMessagingService
that uses OfBiz to
manage the message queue in the database and holds any listeners via a weak reference so that it doesn't keep
listeners alive across plugin restarts, etc.
Polls the database on a regular interval to see if there are actions to perform
Constructor and Description |
---|
OfBizMessageHandlerService(ClusterNodes clusterNodes,
OfBizClusterMessageStore clusterMessageStore,
com.atlassian.event.api.EventPublisher eventPublisher) |
Modifier and Type | Method and Description |
---|---|
List<ClusterMessage> |
receiveMessages() |
void |
registerListener(String channel,
ClusterMessageConsumer consumer)
Register a ClusterMessageConsumer to receive messages sent to the nominated channel.
|
ClusterMessage |
sendMessage(String destinationId,
Message message) |
void |
sendRemote(String channel,
String message)
Sends an inter-node message to registered listeners, listeners on the node the message was raised will not be
notified.
|
void |
start() |
void |
stop() |
void |
unregisterListener(ClusterMessageConsumer consumer)
Removes a ClusterMessageConsumer from all channels.
|
void |
unregisterListener(String channel,
ClusterMessageConsumer consumer)
Removes a ClusterMessageConsumer from the channel.
|
public OfBizMessageHandlerService(ClusterNodes clusterNodes, OfBizClusterMessageStore clusterMessageStore, com.atlassian.event.api.EventPublisher eventPublisher)
@Nullable public ClusterMessage sendMessage(String destinationId, Message message)
sendMessage
in interface MessageHandlerService
public List<ClusterMessage> receiveMessages()
receiveMessages
in interface MessageHandlerService
public void start()
start
in interface MessageHandlerService
public void stop()
stop
in interface MessageHandlerService
public void registerListener(String channel, ClusterMessageConsumer consumer)
ClusterMessagingService
The receive method of the ClusterMessageConsumer will be invoked when a message is sent to a channel it is listening to. Registering a new listener for a channel will not remove any existing listeners on that channel. Listeners are weakly referenced, it is the responsibility of the caller to ensure that listeners are not prematurely garbage collected.
registerListener
in interface ClusterMessagingService
channel
- The name of the channelconsumer
- The consumer that will receive messagespublic void unregisterListener(String channel, ClusterMessageConsumer consumer)
ClusterMessagingService
The ClusterMessageConsumer will no longer receive messages that are sent to the nominated channel.
unregisterListener
in interface ClusterMessagingService
channel
- The name of the channelconsumer
- The consumer to be unregisteredpublic void unregisterListener(ClusterMessageConsumer consumer)
ClusterMessagingService
The ClusterMessageConsumer will no longer receive any messages.
unregisterListener
in interface ClusterMessagingService
consumer
- The consumer to be unregisteredpublic void sendRemote(String channel, String message)
ClusterMessagingService
sendRemote
in interface ClusterMessagingService
channel
- The name of the channel (up to 20 alphanumeric characters in length)message
- The message to send (up to 200 characters in length)Copyright © 2002-2017 Atlassian. All Rights Reserved.