}
}
public void removeSubscriber(DestinationConfig dConfig, boolean remList)
throws JMSException {
AQSession aqSession = null;
AQQueue aqQueue = null;
if (hermes.getSession() != null) {
try {
AQjmsSession aqjmsSession = (AQjmsSession) hermes.getSession();
Class.forName(AQ_DRIVER_CLASS);
Connection conn = aqjmsSession.getDBConnection();
aqSession = AQDriverManager.createAQSession(conn);
aqQueue = aqSession.getQueue(conn.getMetaData().getUserName(),
dConfig.getName());
AQAgent[] aqAgents = aqQueue.getSubscribers();
String clientId = dConfig.getClientID();
clientId = clientId.replaceAll("\"", "");
LOG.info("Client id is " + clientId);
for (int i = 0; i < aqAgents.length; i++) {
// LOG.debug("Durable Subscriber Name is "
// + aqAgents[i].getName());
// AQ keeps them as uppercase, unfortunate
LOG.debug("AQ agent is " + aqAgents[i].getName());
if (aqAgents[i].getName().equals(clientId.toUpperCase())) {
LOG.debug("Before remove subscriber "
+ aqAgents[i].getName());
aqQueue.removeSubscriber(aqAgents[i]);
LOG.info("Successfully removed durable subscriber "
+ clientId + " for topic " + dConfig.getName());
break;
}
}
} catch (AQException e) {
final String msg = "AQ Exception encountered , check log (hermes.log) for more details ";
LOG.error(msg, e);
} catch (SQLException e) {
final String msg = "SQL Exception encountered , check log (hermes.log) for more details ";
LOG.error(msg, e);
} catch (ClassNotFoundException e) {
final String msg = "ClassNotFoundException encountered , check log (hermes.log) for more details ";
LOG.error(msg, e);
} finally {
if (aqQueue != null) {
aqQueue.close();
}
if (aqSession != null) {
aqSession.close();
}
}
}
if (remList)
list.remove(dConfig);