public class MessageDispatcher extends Object implements RequestHandler
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.
Modifier and Type | Field and Description |
---|---|
protected PullPushAdapter |
adapter |
protected Channel |
channel |
protected RequestCorrelator |
corr |
protected org.jgroups.blocks.MessageDispatcher.PullPushHandler |
handler |
protected boolean |
hardware_multicast_supported |
protected Serializable |
id |
protected Address |
local_addr |
protected Log |
log |
protected Collection<Address> |
members |
protected MembershipListener |
membership_listener |
protected MessageListener |
msg_listener |
protected org.jgroups.blocks.MessageDispatcher.ProtocolAdapter |
prot_adapter |
protected RequestHandler |
req_handler |
protected org.jgroups.blocks.MessageDispatcher.TransportAdapter |
transport_adapter |
Modifier and Type | Method and Description |
---|---|
protected GroupRequest |
cast(Collection<Address> dests,
Message msg,
RequestOptions options,
boolean block_for_results) |
RspList |
castMessage(Collection<Address> dests,
Message msg,
RequestOptions options)
Sends a message to the members listed in dests.
|
RspList |
castMessage(Vector dests,
Message msg,
int mode,
long timeout)
Deprecated.
|
RspList |
castMessage(Vector dests,
Message msg,
int mode,
long timeout,
boolean use_anycasting)
Deprecated.
|
RspList |
castMessage(Vector dests,
Message msg,
int mode,
long timeout,
boolean use_anycasting,
RspFilter filter)
Deprecated.
|
NotifyingFuture<RspList> |
castMessageWithFuture(Collection<Address> dests,
Message msg,
RequestOptions options) |
NotifyingFuture<RspList> |
castMessageWithFuture(Vector dests,
Message msg,
int mode,
long timeout,
boolean use_anycasting,
RspFilter filter)
Deprecated.
|
protected void |
correlatorStarted() |
protected RequestCorrelator |
createRequestCorrelator(Object transport,
RequestHandler handler,
Address local_addr) |
void |
done(long req_id) |
Channel |
getChannel()
Offers access to the underlying Channel.
|
boolean |
getConcurrentProcessing()
Deprecated.
|
boolean |
getDeadlockDetection()
Deprecated.
|
protected Collection |
getMembers()
Returns a copy of members
|
MessageListener |
getMessageListener()
Gives access to the currently configured MessageListener.
|
UpHandler |
getProtocolAdapter() |
Object |
handle(Message msg) |
protected void |
installUpHandler(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's
default handler . |
void |
send(Message msg)
Deprecated.
|
Object |
sendMessage(Message msg,
int mode,
long timeout)
Deprecated.
Use
sendMessage(org.jgroups.Message, RequestOptions) instead |
Object |
sendMessage(Message msg,
RequestOptions opts) |
<T> NotifyingFuture<T> |
sendMessageWithFuture(Message msg,
int mode,
long timeout)
Deprecated.
|
<T> NotifyingFuture<T> |
sendMessageWithFuture(Message msg,
RequestOptions options) |
void |
setChannel(Channel ch) |
void |
setConcurrentProcessing(boolean flag)
Deprecated.
|
void |
setDeadlockDetection(boolean flag)
Deprecated.
|
void |
setMembershipListener(MembershipListener l) |
void |
setMessageListener(MessageListener l) |
void |
setRequestHandler(RequestHandler rh) |
void |
start() |
void |
stop() |
protected Channel channel
protected RequestCorrelator corr
protected MessageListener msg_listener
protected MembershipListener membership_listener
protected RequestHandler req_handler
protected org.jgroups.blocks.MessageDispatcher.ProtocolAdapter prot_adapter
protected org.jgroups.blocks.MessageDispatcher.TransportAdapter transport_adapter
protected final Collection<Address> members
protected Address local_addr
protected PullPushAdapter adapter
protected org.jgroups.blocks.MessageDispatcher.PullPushHandler handler
protected Serializable id
protected final Log log
protected boolean hardware_multicast_supported
public MessageDispatcher()
public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2)
@Deprecated public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, boolean deadlock_detection)
@Deprecated public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, boolean deadlock_detection, boolean concurrent_processing)
public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler)
@Deprecated public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean deadlock_detection)
@Deprecated public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean deadlock_detection, boolean concurrent_processing)
@Deprecated public MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2)
@Deprecated public MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, RequestHandler req_handler)
@Deprecated public MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean concurrent_processing)
public UpHandler getProtocolAdapter()
protected Collection getMembers()
@Deprecated public boolean getDeadlockDetection()
@Deprecated public void setDeadlockDetection(boolean flag)
@Deprecated public boolean getConcurrentProcessing()
@Deprecated public void setConcurrentProcessing(boolean flag)
public void start()
protected RequestCorrelator createRequestCorrelator(Object transport, RequestHandler handler, Address local_addr)
protected void correlatorStarted()
public void stop()
public final void setMessageListener(MessageListener l)
public MessageListener getMessageListener()
public final void setMembershipListener(MembershipListener l)
public final void setRequestHandler(RequestHandler rh)
public Channel getChannel()
public void setChannel(Channel ch)
protected void installUpHandler(UpHandler handler, boolean canReplace)
default handler
.
If the relevant handler is already installed, the canReplace
controls whether this method replaces it (after logging a WARN) or simply
leaves handler
uninstalled.
Passing false
as the canReplace
value allows
callers to use this method to install defaults without concern about
inadvertently overriding
handler
- the UpHandler to installcanReplace
- true
if an existing Channel upHandler or
Muxer default upHandler can be replaced; false
if this method shouldn't install@Deprecated public void send(Message msg) throws ChannelNotConnectedException, ChannelClosedException
@Deprecated public RspList castMessage(Vector dests, Message msg, int mode, long timeout)
@Deprecated public RspList castMessage(Vector dests, Message msg, int mode, long timeout, boolean use_anycasting)
@Deprecated public RspList castMessage(Vector dests, Message msg, int mode, long timeout, boolean use_anycasting, RspFilter filter)
public RspList castMessage(Collection<Address> dests, Message msg, RequestOptions options)
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. See RequestOptions
for details@Deprecated public NotifyingFuture<RspList> castMessageWithFuture(Vector dests, Message msg, int mode, long timeout, boolean use_anycasting, RspFilter filter)
public NotifyingFuture<RspList> castMessageWithFuture(Collection<Address> dests, Message msg, RequestOptions options)
protected GroupRequest cast(Collection<Address> dests, Message msg, RequestOptions options, boolean block_for_results)
public void done(long req_id)
@Deprecated public Object sendMessage(Message msg, int mode, long timeout) throws TimeoutException, SuspectedException
sendMessage(org.jgroups.Message, RequestOptions)
insteadTimeoutException
SuspectedException
public Object sendMessage(Message msg, RequestOptions opts) throws TimeoutException, SuspectedException
TimeoutException
SuspectedException
@Deprecated public <T> NotifyingFuture<T> sendMessageWithFuture(Message msg, int mode, long timeout) throws TimeoutException, SuspectedException
TimeoutException
SuspectedException
public <T> NotifyingFuture<T> sendMessageWithFuture(Message msg, RequestOptions options) throws TimeoutException, SuspectedException
TimeoutException
SuspectedException
public Object handle(Message msg)
handle
in interface RequestHandler
Copyright © 2013 JBoss, a division of Red Hat. All Rights Reserved.