Class RpcChannel
java.lang.Object
org.apache.catalina.tribes.group.RpcChannel
- All Implemented Interfaces:
ChannelListener
A channel to handle RPC messaging
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass that holds all response.static classKey used to identify an RPC collector. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intReturn replies from all members.static final intReturn the first reply received.static final intReturn replies from a majority of members.static final intDo not wait for any reply.protected static final StringManagerString manager for this class. -
Constructor Summary
ConstructorsConstructorDescriptionRpcChannel(byte[] rpcId, Channel channel, RpcCallback callback) Create an RPC channel. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccept(Serializable msg, Member sender) Invoked by the channel to determine if the listener will process this message or not.voidRemove this channel listener from the channel.Get the RPC callback handler.Get the underlying channel.intGet the reply message options.byte[]getRpcId()Get the RPC identifier.voidmessageReceived(Serializable msg, Member sender) Receive a message from the channelResponse[]send(Member[] destination, Serializable message, int rpcOptions, int channelOptions, long timeout) Send a message and wait for the response.voidsetCallback(RpcCallback callback) Set the RPC callback handler.voidsetChannel(Channel channel) Set the underlying channel.voidsetReplyMessageOptions(int replyMessageOptions) Set the reply message options.voidsetRpcId(byte[] rpcId) Set the RPC identifier.
-
Field Details
-
sm
String manager for this class. -
FIRST_REPLY
public static final int FIRST_REPLYReturn the first reply received.- See Also:
-
MAJORITY_REPLY
public static final int MAJORITY_REPLYReturn replies from a majority of members.- See Also:
-
ALL_REPLY
public static final int ALL_REPLYReturn replies from all members.- See Also:
-
NO_REPLY
public static final int NO_REPLYDo not wait for any reply.- See Also:
-
-
Constructor Details
-
RpcChannel
Create an RPC channel. You can have several RPC channels attached to a group all separated out by the uniqueness- Parameters:
rpcId- - the unique Id for this RPC groupchannel- Channelcallback- RpcCallback
-
-
Method Details
-
send
public Response[] send(Member[] destination, Serializable message, int rpcOptions, int channelOptions, long timeout) throws ChannelException Send a message and wait for the response.- Parameters:
destination- Member[] - the destination for the message, and the members you request a reply frommessage- Serializable - the message you are sending outrpcOptions- int - FIRST_REPLY, MAJORITY_REPLY or ALL_REPLYchannelOptions- channel sender optionstimeout- long - timeout in milliseconds, if no reply is received within this time null is returned- Returns:
- Response[] - an array of response objects.
- Throws:
ChannelException- Error sending message
-
messageReceived
Description copied from interface:ChannelListenerReceive a message from the channel- Specified by:
messageReceivedin interfaceChannelListener- Parameters:
msg- Serializablesender- - the source of the message
-
breakdown
public void breakdown()Remove this channel listener from the channel. -
accept
Description copied from interface:ChannelListenerInvoked by the channel to determine if the listener will process this message or not.- Specified by:
acceptin interfaceChannelListener- Parameters:
msg- Serializablesender- Member- Returns:
- boolean
-
getChannel
-
getCallback
-
getRpcId
public byte[] getRpcId()Get the RPC identifier.- Returns:
- the RPC ID
-
setChannel
Set the underlying channel.- Parameters:
channel- the channel
-
setCallback
Set the RPC callback handler.- Parameters:
callback- the callback
-
setRpcId
public void setRpcId(byte[] rpcId) Set the RPC identifier.- Parameters:
rpcId- the RPC ID
-
getReplyMessageOptions
public int getReplyMessageOptions()Get the reply message options.- Returns:
- the reply message options
-
setReplyMessageOptions
public void setReplyMessageOptions(int replyMessageOptions) Set the reply message options.- Parameters:
replyMessageOptions- the reply message options
-