Represents an event returned by channel.receive() , as requested by
channel.getState() previously.
Allows applications using a channel in a pull mode to receive a state from
another channel instance providing state. Channels have to be configured with
STREAMING_STATE_TRANSFER protocol rather than the default
STATE_TRANSFER protocol in order to receive this event.
The following code demonstrate how to pull events from a channel, processing
StreamingSetStateEvent and retrieving hypothetical state in the
form of LinkedList from event's InputStream reference.
Object obj=channel.receive(0);
if(obj instanceof StreamingSetStateEvent) {
StreamingSetStateEvent evt=(StreamingSetStateEvent)obj;
ObjectInputStream ois = null;
try {
ois = new ObjectInputStream(evt.getArg());
state = (LinkedList)ois.readObject();
} catch (Exception e) {}
finally
{
try {
ois.close();
} catch (IOException e) {
System.err.println(e);
}
}
}
author: Vladimir Blagojevic See Also: org.jgroups.JChannel.getState(Addresslong) See Also: org.jgroups.StreamingMessageListener.setState(InputStream) since: 2.4 |