this.message = message;
}
public void run(BigInteger sessionRefId, long timestamp) {
SessionProtocol protocol =
sessionService.getSessionProtocol(sessionRefId);
if (protocol != null) {
Map<BigInteger, LocalMemberInfo> channelMap =
localPerSessionChannelMap.get(sessionRefId);
if (channelMap == null) {
// The session doesn't belong to any channels.
return;
}
// There is a small window here where the channelMap may
// have been removed from the localPerSessionChannelMap by a
// disconnect handler after it has been retrieved from the map
// by this task above. Therefore, we need to check if
// disconnection is in progress before synchronizing on the
// channelMap
LocalMemberInfo memberInfo = null;
synchronized (localSessionDisconnectingSet) {
if (localSessionDisconnectingSet.contains(sessionRefId)) {
// The session is disconnecting so the channelMap
// has been removed
return;
}
memberInfo = channelMap.get(channelRefId);
}
if (memberInfo == null) {
// The session is no longer a member.
return;
}
if (memberInfo.msgTimestamp > timestamp) {
// If session's message timestamp for this channel is
// greater than the timestamp of the message to be
// delivered, then this is an earlier message sent
// before the session joined the channel. Therefore
// don't deliver the message.
return;
}
memberInfo.msgTimestamp = timestamp;
try {
protocol.channelMessage(
channelRefId, ByteBuffer.wrap(message), delivery);
} catch (IOException e) {
logger.logThrow(Level.WARNING, e, "channelMessage " +
"session:{0} channel:{0} throws",
sessionRefId, channelRefId);