List<SimpleApnsPushNotification> notifications = new ArrayList<SimpleApnsPushNotification>(); if (cause instanceof SSLException || cause instanceof SSLHandshakeException || cause instanceof ClosedChannelException) { //cert is probably bad so shut it down. if (!pushManager.isShutDown()) { pushManager.unregisterFailedConnectionListener(this); BlockingQueue notificationQueue = pushManager.getQueue(); if(notificationQueue !=null){ LinkedBlockingQueue<SimpleApnsPushNotification> queue = ( LinkedBlockingQueue<SimpleApnsPushNotification> )notificationQueue; pushManager.shutdown(); } catch (InterruptedException ie) { logger.error("Failed to stop push services", ie); pushManager.getQueue().clear();
@Override public void removeInactiveDevices() throws Exception { PushManager<SimpleApnsPushNotification> pushManager = getPushManager(notifier); pushManager.requestExpiredTokens(); }
new PushManager<SimpleApnsPushNotification>( apnsEnvironment, sslContext, "ApnsPushManager-" + product.getId()); pushManager.registerRejectedNotificationListener(new PushRejectedNotificationListener()); pushManager.registerFailedConnectionListener(new PushFailedConnectionListener()); pushManager.start();
@Override public void destroy() throws Exception { logger.info("{}. destroy. mapping={}", APNSKeeper.class.getSimpleName(), mapping); Iterator<Integer> iter = mapping.keySet().iterator(); while (iter.hasNext()) { Integer productId = iter.next(); PushManager<SimpleApnsPushNotification> pm = mapping.get(productId); try { logger.info("{}. destroy. 准备shutdown PushManager... pm={}", APNSKeeper.class.getSimpleName(), pm); long start = System.currentTimeMillis(); pm.shutdown(); long end = System.currentTimeMillis(); logger.info("{}. destroy. 结束shutdown PushManager. pm=={}, duration={}", APNSKeeper.class.getSimpleName(), pm, (end-start)); } catch (Exception e) { logger.error(e.getMessage(), e); } } }
message.setStatus(cc.getUserId(), new PushStatus(PushStatus.APNSTokenInvalid)); }else { service.getQueue().put(e); message.setStatus(cc.getUserId(), new PushStatus(PushStatus.APNSSent)); ClientServiceImpl.instance.updateBadge(cc.getUserId(), 1);
@Override public void handleFailedConnection( final PushManager<? extends SimpleApnsPushNotification> pushManager, final Throwable cause) { logger.error(pushManager.getName() + " failed to connect Apple APNS server. ", cause); if (cause instanceof SSLHandshakeException) { // This is probably a permanent failure, and we should shut down // the PushManager. } } }
@Override public void handleRejectedNotification( final PushManager<? extends SimpleApnsPushNotification> pushManager, final SimpleApnsPushNotification notification, final RejectedNotificationReason reason) { logger.error("[{}] {} was rejected with rejection reason {}\n", pushManager.getName(), notification, reason); SimpleApnsPushNotificationWithId item = (SimpleApnsPushNotificationWithId)notification; PayloadServiceImpl.instance.updateSendStatus(item.paylodId, item.getUserId(), new PushStatus(PushStatus.APNSTokenInvalid)); } }