ClusterListener (Apache Tomcat 11.0.24 API Documentation)
Description: declaration: package: org.apache.catalina.ha, class: ClusterListener

# Class ClusterListener

java.lang.Object
org.apache.catalina.ha.ClusterListener

All Implemented Interfaces:
  `ChannelListener`

Direct Known Subclasses:
  `ClusterSessionListener, FarmWarDeployer`

public abstract class ClusterListener extends Object implements ChannelListener
Receive SessionID cluster change from other backup node after primary session node is failed.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected CatalinaCluster`
  `cluster`
  The cluster associated with this listener.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ClusterListener()`
  Default constructor for ClusterListener.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final boolean`
  `accept(Serializable msg, Member member)`
  Invoked by the channel to determine if the listener will process this message or not.
  `abstract boolean`
  `accept(ClusterMessage msg)`
  Accept only a certain type of messages.
  `CatalinaCluster`
  `getCluster()`
  Returns the cluster associated with this listener.
  `final void`
  `messageReceived(Serializable msg, Member member)`
  Receive a message from the channel
  `abstract void`
  `messageReceived(ClusterMessage msg)`
  Callback from the cluster, when a message is received, The cluster will broadcast it invoking the messageReceived on the receiver.
  `void`
  `setCluster(CatalinaCluster cluster)`
  Sets the cluster associated with this listener.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### cluster

    protected CatalinaCluster cluster
    The cluster associated with this listener.

- ## Constructor Details

  - ### ClusterListener

    public ClusterListener()
    Default constructor for ClusterListener.

- ## Method Details

  - ### getCluster

    public CatalinaCluster getCluster()
    Returns the cluster associated with this listener.
    Returns:
      the cluster

  - ### setCluster

    public void setCluster(CatalinaCluster cluster)
    Sets the cluster associated with this listener.
    Parameters:
      `cluster` - the cluster

  - ### messageReceived

    public final void messageReceived(Serializable msg, Member member)
    Description copied from interface: `ChannelListener`
    Receive a message from the channel
    Specified by:
      `messageReceived` in interface `ChannelListener`
    Parameters:
      `msg` - Serializable
      `member` - - the source of the message

  - ### accept

    public final boolean accept(Serializable msg, Member member)
    Description copied from interface: `ChannelListener`
    Invoked by the channel to determine if the listener will process this message or not.
    Specified by:
      `accept` in interface `ChannelListener`
    Parameters:
      `msg` - Serializable
      `member` - Member
    Returns:
      boolean

  - ### messageReceived

    public abstract void messageReceived(ClusterMessage msg)
    Callback from the cluster, when a message is received, The cluster will broadcast it invoking the messageReceived on the receiver.
    Parameters:
      `msg` - the message received from the cluster

  - ### accept

    public abstract boolean accept(ClusterMessage msg)
    Accept only a certain type of messages.
    Parameters:
      `msg` - the message
    Returns:
      `true` to indicate that messageReceived should be invoked. If `false` is returned, the messageReceived method will not be invoked.