// If this Channel was used for Publish and Unsubscribe flows, just
// remove it from the HewdigPublisher's host2Channel map. We will
// re-establish a Channel connection to that server when the next
// publish/unsubscribe request to a topic that the server owns occurs.
PubSubData origSubData = subHandler.getOrigSubData();
// Now determine what type of operation this channel was used for.
if (origSubData == null) {
// Only remove the Channel from the mapping if this current
// disconnected channel is the same as the cached entry.
// Due to race concurrency situations, it is possible to
// create multiple channels to the same host for publish
// and unsubscribe requests.
if (pub.host2Channel.containsKey(host) && pub.host2Channel.get(host).equals(ctx.getChannel())) {
if (logger.isDebugEnabled())
logger.debug("Disconnected channel for host: " + host
+ " was for Publish/Unsubscribe requests so remove all references to it.");
pub.host2Channel.remove(host);
client.clearAllTopicsForHost(host);
}
} else {
// Subscribe channel disconnected so first close and clear all
// cached Channel data set up for this topic subscription.
sub.closeSubscription(origSubData.topic, origSubData.subscriberId);
client.clearAllTopicsForHost(host);
// Since the connection to the server host that was responsible
// for the topic died, we are not sure about the state of that
// server. Resend the original subscribe request data to the default
// server host/VIP. Also clear out all of the servers we've
// contacted or attempted to from this request as we are starting a
// "fresh" subscribe request.
origSubData.clearServersList();
// Set a new type of VoidCallback for this async call. We need this
// hook so after the subscribe reconnect has completed, delivery for
// that topic subscriber should also be restarted (if it was that
// case before the channel disconnect).
origSubData.callback = new SubscribeReconnectCallback(origSubData, client, subHandler.getMessageHandler());