@Override public void onException(IOException e) { monitor.setMQServerStatusDown(); }
@Override public void onCommand(Object o) { monitor.setMQServerStatusUp(); }
public JMSCacheMessageListener() { tridionIsNamespaceAware = checkNamespaceAware(); }
@Override public void onMessage(Message message) { CacheEvent event = getCacheEvent(message); if (event != null) { switch (event.getType()) { case CacheEvent.INVALIDATE: LOG.debug("Invalidate " + event); Serializable key = event.getKey(); cacheInvalidator.invalidate(stripNamespaceIfRequired(key.toString())); monitor.setMQServerStatusUp(); break; case CacheEvent.FLUSH: LOG.debug("Flush " + event); monitor.setMQServerStatusUp(); break; default: break; } } }
public void setMQServerStatusUp() { if (isMQServerDown()) { LOG.debug("Detected MQ server activity. Setting status UP"); setMQServerStatus(MQServerStatus.UP); } }
public void setMQServerStatusDown() { if (isMQServerUp()) { LOG.debug("Detected MQ server connection dropped. Setting status DOWN"); setMQServerStatus(MQServerStatus.DOWN); } }
@Override public void run() { LOG.debug("Monitor thread running"); MQServerStatus previousServerStatus = MQServerStatus.UP; try { while (!Thread.currentThread().isInterrupted()) { LOG.debug("JMS MQ server is {} ", serverStatus); if (cacheInvalidator != null) { if (isMQServerDown()) { cacheInvalidator.flush(); } else if (previousServerStatus == MQServerStatus.DOWN) { LOG.debug("JMS MQ server recovered. Flush local cache one more time."); cacheInvalidator.flush(); } previousServerStatus = serverStatus; } Thread.sleep(monitorServiceInterval); } } catch (InterruptedException e) { LOG.debug("Cache monitor thread interrupted"); Thread.currentThread().interrupt(); } } };
@Override public void transportInterupted() { monitor.setMQServerStatusDown(); }
@Override public void transportResumed() { monitor.setMQServerStatusUp(); } }
@Override public void handleError(Throwable error) { LOG.error("JMS exception occurred", error); monitor.setMQServerStatusDown(); }
@Override public void onException(JMSException jmse) { LOG.error("JMS exception occurred", jmse); monitor.setMQServerStatusDown(); }