Class MessageDispatcher
- All Implemented Interfaces:
RequestHandler
- Direct Known Subclasses:
MuxMessageDispatcher,RpcDispatcher
Channels are simple patterns to asynchronously send a receive messages. However, a significant number of communication patterns in group communication require synchronous communication. For example, a sender would like to send a message to the group and wait for all responses. Or another application would like to send a message to the group and wait only until the majority of the receivers have sent a response, or until a timeout occurred. MessageDispatcher offers a combination of the above pattern with other patterns.
Used on top of channel to implement group requests. Client's handle()
method is called when request is received. Is the equivalent of RpcProtocol on
the application instead of protocol level.
- Author:
- Bela Ban
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PullPushAdapterprotected Channelprotected RequestCorrelatorprotected org.jgroups.blocks.MessageDispatcher.PullPushHandlerprotected booleanprotected Serializableprotected Addressprotected final Logprotected final Collection<Address> protected MembershipListenerprotected MessageListenerprotected org.jgroups.blocks.MessageDispatcher.ProtocolAdapterprotected RequestHandlerprotected org.jgroups.blocks.MessageDispatcher.TransportAdapter -
Constructor Summary
ConstructorsConstructorDescriptionMessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2) Deprecated.MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, RequestHandler req_handler) Deprecated.MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean concurrent_processing) Deprecated.MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2) MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, boolean deadlock_detection) Deprecated.MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, boolean deadlock_detection, boolean concurrent_processing) Deprecated.MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler) MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean deadlock_detection) Deprecated.MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean deadlock_detection, boolean concurrent_processing) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionprotected GroupRequestcast(Collection<Address> dests, Message msg, RequestOptions options, boolean block_for_results) castMessage(Collection<Address> dests, Message msg, RequestOptions options) Sends a message to the members listed in dests.castMessage(Vector dests, Message msg, int mode, long timeout) Deprecated.castMessage(Vector dests, Message msg, int mode, long timeout, boolean use_anycasting) Deprecated.castMessage(Vector dests, Message msg, int mode, long timeout, boolean use_anycasting, RspFilter filter) Deprecated.castMessageWithFuture(Collection<Address> dests, Message msg, RequestOptions options) castMessageWithFuture(Vector dests, Message msg, int mode, long timeout, boolean use_anycasting, RspFilter filter) Deprecated.protected voidprotected RequestCorrelatorcreateRequestCorrelator(Object transport, RequestHandler handler, Address local_addr) voiddone(long req_id) Offers access to the underlying Channel.booleanDeprecated.booleanDeprecated.protected CollectionReturns a copy of membersGives access to the currently configured MessageListener.protected voidinstallUpHandler(UpHandler handler, boolean canReplace) Sets the given UpHandler as the UpHandler for the channel, or, if the channel already has a Muxer installed as it's UpHandler, sets the given handler as the Muxer'sdefault handler.voidDeprecated.sendMessage(Message msg, int mode, long timeout) Deprecated.sendMessage(Message msg, RequestOptions opts) <T> NotifyingFuture<T> sendMessageWithFuture(Message msg, int mode, long timeout) Deprecated.<T> NotifyingFuture<T> sendMessageWithFuture(Message msg, RequestOptions options) voidsetChannel(Channel ch) voidsetConcurrentProcessing(boolean flag) Deprecated.voidsetDeadlockDetection(boolean flag) Deprecated.final voidfinal voidfinal voidvoidstart()voidstop()
-
Field Details
-
channel
-
corr
-
msg_listener
-
membership_listener
-
req_handler
-
prot_adapter
protected org.jgroups.blocks.MessageDispatcher.ProtocolAdapter prot_adapter -
transport_adapter
protected org.jgroups.blocks.MessageDispatcher.TransportAdapter transport_adapter -
members
-
local_addr
-
adapter
-
handler
protected org.jgroups.blocks.MessageDispatcher.PullPushHandler handler -
id
-
log
-
hardware_multicast_supported
protected boolean hardware_multicast_supported
-
-
Constructor Details
-
MessageDispatcher
public MessageDispatcher() -
MessageDispatcher
-
MessageDispatcher
@Deprecated public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, boolean deadlock_detection) Deprecated. -
MessageDispatcher
@Deprecated public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, boolean deadlock_detection, boolean concurrent_processing) Deprecated. -
MessageDispatcher
public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler) -
MessageDispatcher
@Deprecated public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean deadlock_detection) Deprecated. -
MessageDispatcher
@Deprecated public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean deadlock_detection, boolean concurrent_processing) Deprecated. -
MessageDispatcher
@Deprecated public MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2) Deprecated. -
MessageDispatcher
@Deprecated public MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, RequestHandler req_handler) Deprecated. -
MessageDispatcher
@Deprecated public MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean concurrent_processing) Deprecated.
-
-
Method Details
-
getProtocolAdapter
-
getMembers
Returns a copy of members -
getDeadlockDetection
Deprecated. -
setDeadlockDetection
Deprecated. -
getConcurrentProcessing
Deprecated. -
setConcurrentProcessing
Deprecated. -
start
public void start() -
createRequestCorrelator
protected RequestCorrelator createRequestCorrelator(Object transport, RequestHandler handler, Address local_addr) -
correlatorStarted
protected void correlatorStarted() -
stop
public void stop() -
setMessageListener
-
getMessageListener
Gives access to the currently configured MessageListener. Returns null if there is no configured MessageListener. -
setMembershipListener
-
setRequestHandler
-
getChannel
Offers access to the underlying Channel.- Returns:
- a reference to the underlying Channel.
-
setChannel
-
installUpHandler
Sets the given UpHandler as the UpHandler for the channel, or, if the channel already has a Muxer installed as it's UpHandler, sets the given handler as the Muxer'sdefault handler. If the relevant handler is already installed, thecanReplacecontrols whether this method replaces it (after logging a WARN) or simply leaveshandleruninstalled.Passing
falseas thecanReplacevalue allows callers to use this method to install defaults without concern about inadvertently overriding- Parameters:
handler- the UpHandler to installcanReplace-trueif an existing Channel upHandler or Muxer default upHandler can be replaced;falseif this method shouldn't install
-
send
@Deprecated public void send(Message msg) throws ChannelNotConnectedException, ChannelClosedException Deprecated. -
castMessage
Deprecated. -
castMessage
@Deprecated public RspList castMessage(Vector dests, Message msg, int mode, long timeout, boolean use_anycasting) Deprecated. -
castMessage
@Deprecated public RspList castMessage(Vector dests, Message msg, int mode, long timeout, boolean use_anycasting, RspFilter filter) Deprecated. -
castMessage
Sends a message to the members listed in dests. If dests is null, the message is sent to all current group members.- Parameters:
dests- A list of group members. The message is sent to all members of the current group if nullmsg- The message to be sentoptions- A set of options that govern the call. SeeRequestOptionsfor details- Returns:
- Since:
- 2.9
-
castMessageWithFuture
@Deprecated public NotifyingFuture<RspList> castMessageWithFuture(Vector dests, Message msg, int mode, long timeout, boolean use_anycasting, RspFilter filter) Deprecated. -
castMessageWithFuture
public NotifyingFuture<RspList> castMessageWithFuture(Collection<Address> dests, Message msg, RequestOptions options) -
cast
protected GroupRequest cast(Collection<Address> dests, Message msg, RequestOptions options, boolean block_for_results) -
done
public void done(long req_id) -
sendMessage
@Deprecated public Object sendMessage(Message msg, int mode, long timeout) throws TimeoutException, SuspectedException Deprecated.UsesendMessage(org.jgroups.Message, RequestOptions)insteadSends a message to a single member (destination = msg.dest) and returns the response. The message's destination must be non-zero !- Throws:
TimeoutExceptionSuspectedException
-
sendMessage
public Object sendMessage(Message msg, RequestOptions opts) throws TimeoutException, SuspectedException - Throws:
TimeoutExceptionSuspectedException
-
sendMessageWithFuture
@Deprecated public <T> NotifyingFuture<T> sendMessageWithFuture(Message msg, int mode, long timeout) throws TimeoutException, SuspectedException Deprecated.- Throws:
TimeoutExceptionSuspectedException
-
sendMessageWithFuture
public <T> NotifyingFuture<T> sendMessageWithFuture(Message msg, RequestOptions options) throws TimeoutException, SuspectedException - Throws:
TimeoutExceptionSuspectedException
-
handle
- Specified by:
handlein interfaceRequestHandler
-
sendMessage(org.jgroups.Message, RequestOptions)instead