public VariantErrorStatus(final FlatPushMessageInformation pushMessageInformation, final Variant variant, final String errorReason) { this.pushMessageVariantId = new StringBuilder(pushMessageInformation.getId()).append(':').append(variant.getVariantID()).toString(); this.variantID = variant.getVariantID(); this.pushJobId = pushMessageInformation.getId(); this.errorReason = errorReason; this.pushMessageInformation = pushMessageInformation; this.variant = variant; }
public VariantErrorStatus(final FlatPushMessageInformation pushMessageInformation, final Variant variant, final String errorReason) { this.pushMessageVariantId = new StringBuilder(pushMessageInformation.getId()).append(':').append(variant.getVariantID()).toString(); this.variantID = variant.getVariantID(); this.pushJobId = pushMessageInformation.getId(); this.errorReason = errorReason; this.pushMessageInformation = pushMessageInformation; this.variant = variant; }
private void putDeviceCountIntoResponseHeaders(PushApplication app, ResponseBuilder response) { long appCount = 0; for (Variant variant : app.getVariants()) { long variantCount = installationDao.getNumberOfDevicesForVariantID(variant.getVariantID()); appCount += variantCount; response.header("deviceCount_variant_" + variant.getVariantID(), variantCount); } response.header("deviceCount_app_" + app.getPushApplicationID(), appCount); }
clientInstallationService.findInstallationForVariantByDeviceToken(variant.getVariantID(), token);
@Override @Asynchronous public void unsubscribeOldTopics(Installation installation) { FCMTopicManager topicManager = new FCMTopicManager((AndroidVariant) installation.getVariant()); Set<String> oldCategories = topicManager.getSubscribedCategories(installation); // Remove current categories from the set of old ones oldCategories.removeAll(convertToNames(installation.getCategories())); // Remove global variant topic because we don't want to unsubscribe it oldCategories.remove(installation.getVariant().getVariantID()); for (String categoryName : oldCategories) { topicManager.unsubscribe(installation, categoryName); } }
clientInstallationService.removeInstallationForVariantByDeviceToken(variant.getVariantID(), oldToken);
Set<String> existingTokens = installationDao.findAllDeviceTokenForVariantID(variant.getVariantID());
topics.addAll(TokenLoaderUtils.extractFCMTopics(criteria, variant.getVariantID())); tokenStream = clientInstallationService.findAllOldGoogleCloudMessagingDeviceTokenForVariantIDByCriteria(variant.getVariantID(), categories, aliases, deviceTypes, configuration.tokensToLoad(), lastTokenFromPreviousBatch) .fetchSize(configuration.batchSize()) .executeQuery(); tokenStream = clientInstallationService.findAllDeviceTokenForVariantIDByCriteria(variant.getVariantID(), categories, aliases, deviceTypes, configuration.tokensToLoad(), lastTokenFromPreviousBatch) .fetchSize(configuration.batchSize()) .executeQuery(); logger.info(String.format("Loaded batch #%s, containing %d tokens, for %s variant (%s)", serialId, tokens.size() ,variant.getType().getTypeName(), variant.getVariantID())); } else { logger.debug(String.format("Failing token loading transaction for batch token #%s for %s variant (%s), since queue is full, will retry...", serialId, variant.getType().getTypeName(), variant.getVariantID())); context.setRollbackOnly(); return; logger.info("Loaded batch #{}, containing {} tokens, for {} variant ({})", serialId, tokens.size() ,variant.getType().getTypeName(), variant.getVariantID()); logger.debug(String.format("Ending token loading transaction for %s variant (%s)", variant.getType().getTypeName(), variant.getVariantID())); nextBatchEvent.fire(new MessageHolderWithVariants(msg.getPushMessageInformation(), message, msg.getVariantType(), variants, serialId, lastTokenInBatch)); } else { logger.debug("All batches for {} variant were loaded ({})", variant.getType().getTypeName(), variant.getVariantID());
/** * Receives a {@link UnifiedPushMessage} and list of device tokens that the message should be sent to, selects appropriate sender implementation that * the push notifications are submitted to. * * @param msg object containing details about the payload and the related device tokens */ public void sendMessagesToPushNetwork(@Observes @Dequeue MessageHolderWithTokens msg) { final Variant variant = msg.getVariant(); final UnifiedPushMessage unifiedPushMessage = msg.getUnifiedPushMessage(); final Collection<String> deviceTokens = msg.getDeviceTokens(); logger.info("Received UnifiedPushMessage from JMS queue, will now trigger the Push Notification delivery for the %s variant ({})", variant.getType().getTypeName(), variant.getVariantID()); senders.select(new SenderTypeLiteral(variant.getType())).get() .sendPushMessage(variant, deviceTokens, unifiedPushMessage, msg.getPushMessageInformation().getId(), new SenderServiceCallback( variant, deviceTokens.size(), msg.getPushMessageInformation() ) ); }
if (!expiredClientIdentifiers.isEmpty()) { logger.info(String.format("Deleting '%d' expired WNS installations", expiredClientIdentifiers.size())); clientInstallationService.removeInstallationsForVariantByDeviceTokens(variant.getVariantID(), expiredClientIdentifiers);
/** * Receives a {@link UnifiedPushMessage} and list of device tokens that the message should be sent to, selects appropriate sender implementation that * the push notifications are submitted to. * * @param msg object containing details about the payload and the related device tokens */ public void sendMessagesToPushNetwork(@Observes @Dequeue MessageHolderWithTokens msg) { final Variant variant = msg.getVariant(); final UnifiedPushMessage unifiedPushMessage = msg.getUnifiedPushMessage(); final Collection<String> deviceTokens = msg.getDeviceTokens(); logger.info("Received UnifiedPushMessage from JMS queue, will now trigger the Push Notification delivery for the %s variant ({})", variant.getType().getTypeName(), variant.getVariantID()); senders.select(new SenderTypeLiteral(variant.getType())).get() .sendPushMessage(variant, deviceTokens, unifiedPushMessage, msg.getPushMessageInformation().getId(), new SenderServiceCallback( variant, deviceTokens.size(), msg.getPushMessageInformation() ) ); }
if (!expiredClientIdentifiers.isEmpty()) { logger.info(String.format("Deleting '%d' expired WNS installations", expiredClientIdentifiers.size())); clientInstallationService.removeInstallationsForVariantByDeviceTokens(variant.getVariantID(), expiredClientIdentifiers);
topics.addAll(TokenLoaderUtils.extractFCMTopics(criteria, variant.getVariantID())); tokenStream = clientInstallationService.findAllOldGoogleCloudMessagingDeviceTokenForVariantIDByCriteria(variant.getVariantID(), categories, aliases, deviceTypes, configuration.tokensToLoad(), lastTokenFromPreviousBatch) .fetchSize(configuration.batchSize()) .executeQuery(); tokenStream = clientInstallationService.findAllDeviceTokenForVariantIDByCriteria(variant.getVariantID(), categories, aliases, deviceTypes, configuration.tokensToLoad(), lastTokenFromPreviousBatch) .fetchSize(configuration.batchSize()) .executeQuery(); logger.info(String.format("Loaded batch #%s, containing %d tokens, for %s variant (%s)", serialId, tokens.size() ,variant.getType().getTypeName(), variant.getVariantID())); } else { logger.debug(String.format("Failing token loading transaction for batch token #%s for %s variant (%s), since queue is full, will retry...", serialId, variant.getType().getTypeName(), variant.getVariantID())); context.setRollbackOnly(); return; logger.info("Loaded batch #{}, containing {} tokens, for {} variant ({})", serialId, tokens.size() ,variant.getType().getTypeName(), variant.getVariantID()); logger.debug(String.format("Ending token loading transaction for %s variant (%s)", variant.getType().getTypeName(), variant.getVariantID())); nextBatchEvent.fire(new MessageHolderWithVariants(msg.getPushMessageInformation(), message, msg.getVariantType(), variants, serialId, lastTokenInBatch)); } else { logger.debug("All batches for {} variant were loaded ({})", variant.getType().getTypeName(), variant.getVariantID());
@Override @Asynchronous public void addInstallation(Variant variant, Installation entity) { // does it already exist ? Installation installation = this.findInstallationForVariantByDeviceToken(variant.getVariantID(), entity.getDeviceToken()); // Needed for the Admin UI Only. Help for setting up Routes entity.setPlatform(variant.getType().getTypeName()); // new device/client ? if (installation == null) { logger.trace("Performing new device/client registration"); // store the installation: storeInstallationAndSetReferences(variant, entity); } else { // We only update the metadata, if the device is enabled: if (installation.isEnabled()) { logger.trace("Updating received metadata for an 'enabled' installation"); // fix variant property of installation object installation.setVariant(variant); // update the entity: this.updateInstallation(installation, entity); } } }