The low level functions of the communication mechanism, such as group membership and message transport, are provided by channels.
Figure 7.44. Channel Class
public class JChannel ...
{
// Initialization can accept either options or configuration file
public JChannel (String props) throws Exception;
// Join a group with a given name
public void connect (String cluster) throws Exception;
public void disconnect ();
// View is the current list of members
public View getView ();
public void send (Message msg) throws Exception;
public void send (Address dst, byte[] buf) throws Exception;
public void send (Address dst, Serializable obj) throws Exception;
public void receive (Message msg);
// Asynchronous notification about messages and membership is available
public void setReceiver (Receiver r);
...
}
Figure 7.45. Receiver Interface
public interface MessageListener
{
void receive (Message msg);
// Group members can share state
void getState (OutputStream output) throws Exception;
void setState(InputStream input) throws Exception;
}
public interface MembershipListener
{
// Notification about membership view change
public void viewAccepted (View view);
// Indication of suspect member before actual removal
public void suspect (Object suspected);
// Notifies about temporary suspension during view update
public void block ();
public void unblock ();
}
public interface Receiver extends MessageListener, MembershipListener;