@ExperimentalApi public interface

ClusterMessagingService

com.atlassian.jira.cluster.ClusterMessagingService
Known Indirect Subclasses

@ExperimentalApi

This interface is considered usable by external developers but its contracts have not stabilized.

Experimental APIs may be changed at any time before being marked @Internal or @PublicApi.

Class Overview

Service responsible for notifying ClusterMessageConsumer instances when messages are waiting to be processed. Also provides a mechanism for broadcasting messages to a channel.

Summary

Public Methods
void registerListener(String channel, ClusterMessageConsumer consumer)
Register a ClusterMessageConsumer to receive messages sent to the nominated channel.
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 unregisterListener(ClusterMessageConsumer consumer)
Removes a ClusterMessageConsumer from all channels.
void unregisterListener(String channel, ClusterMessageConsumer consumer)
Removes a ClusterMessageConsumer from the channel.

Public Methods

public void registerListener (String channel, ClusterMessageConsumer consumer)

Register a ClusterMessageConsumer to receive messages sent to the nominated channel.

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.

Parameters
channel The name of the channel
consumer The consumer that will receive messages

public 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.

Parameters
channel The name of the channel (up to 20 alphanumeric characters in length)
message The message to send (up to 200 characters in length)

public void unregisterListener (ClusterMessageConsumer consumer)

Removes a ClusterMessageConsumer from all channels.

The ClusterMessageConsumer will no longer receive any messages.

Parameters
consumer The consumer to be unregistered

public void unregisterListener (String channel, ClusterMessageConsumer consumer)

Removes a ClusterMessageConsumer from the channel.

The ClusterMessageConsumer will no longer receive messages that are sent to the nominated channel.

Parameters
channel The name of the channel
consumer The consumer to be unregistered