} catch (RuntimeException re) {
String errMsg = "RuntimeException caught when instantiating message filter for (topic:"
+ topic.toStringUtf8() + ", subscriber:" + subscriberId.toStringUtf8() + ")."
+ "It might be introduced by programming error in message filter.";
logger.error(errMsg, re);
PubSubException pse = new PubSubException.InvalidMessageFilterException(errMsg, re);
subStats.incrementFailedOps();
// we should not close the subscription channel, just response error
// client decide to close it or not.
channel.write(PubSubResponseUtils.getResponseForException(pse, request.getTxnId()));
return;
} catch (Throwable t) {
String errMsg = "Failed to instantiate message filter for (topic:" + topic.toStringUtf8()
+ ", subscriber:" + subscriberId.toStringUtf8() + ").";
logger.error(errMsg, t);
PubSubException pse = new PubSubException.InvalidMessageFilterException(errMsg, t);
subStats.incrementFailedOps();
channel.write(PubSubResponseUtils.getResponseForException(pse, request.getTxnId()))
.addListener(ChannelFutureListener.CLOSE);
return;
}
boolean forceAttach = false;
if (subRequest.hasForceAttach()) {
forceAttach = subRequest.getForceAttach();
}
// Try to store the subscription channel for the topic subscriber
Channel oldChannel = subChannelMgr.put(topicSub, channel, forceAttach);
if (null != oldChannel) {
PubSubException pse = new PubSubException.TopicBusyException(
"Subscriber " + subscriberId.toStringUtf8() + " for topic " + topic.toStringUtf8()
+ " is already being served on a different channel " + oldChannel + ".");
subStats.incrementFailedOps();
channel.write(PubSubResponseUtils.getResponseForException(pse, request.getTxnId()))
.addListener(ChannelFutureListener.CLOSE);