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 FlatPushMessageInformation storeNewRequestFrom(String pushAppId, String json, String ipAddress, String clientIdentifier) { final FlatPushMessageInformation information = new FlatPushMessageInformation(); information.setRawJsonMessage(json); information.setIpAddress(ipAddress); information.setPushApplicationId(pushAppId); information.setClientIdentifier(clientIdentifier); logger.trace("starting to track a new Push Message request in the database"); flatPushMessageInformationDao.create(information); flatPushMessageInformationDao.flushAndClear(); return information; }
public void appendError(final FlatPushMessageInformation pushMessageInformation, final Variant variant, final String errorMessage) { final VariantErrorStatus ves = new VariantErrorStatus(pushMessageInformation, variant, errorMessage); pushMessageInformation.getErrors().add(ves); try { flatPushMessageInformationDao.update(pushMessageInformation); } catch (Exception e) { logger.info("Failed to save pushMessageInformation: {}", e.getMessage()); logger.debug("Details:", e); } }
public void updateAnalytics(String aerogearPushId) { FlatPushMessageInformation pushMessageInformation = this.getPushMessageInformation(aerogearPushId); if (pushMessageInformation != null) { //if we are here, app has been opened due to a push message //if the firstOpenDate is not null that means it's no the first one, let's update the lastDateOpen if (pushMessageInformation.getFirstOpenDate() != null) { pushMessageInformation.setLastOpenDate(new Date()); } else { pushMessageInformation.setFirstOpenDate(new Date()); pushMessageInformation.setLastOpenDate(new Date()); } //update the general counter logger.trace("Incrementing 'open counter' for Push Notification '{}' ", aerogearPushId); pushMessageInformation.incrementAppOpenCounter(); } } }
private List<Application> wrapApplication(List<FlatPushMessageInformation> pushMessageInformations) { final List<Application> applications = new ArrayList<>(pushMessageInformations.size()); pushMessageInformations.forEach(pushMessageInformation -> { final String applicationName = pushApplicationDao.findByPushApplicationID(pushMessageInformation.getPushApplicationId()).getName(); final Application application = new Application(applicationName, pushMessageInformation.getPushApplicationId(), pushMessageInformation.getSubmitDate()); applications.add(application); }); return applications; } }
private List<Application> wrapApplication(List<FlatPushMessageInformation> pushMessageInformations) { final List<Application> applications = new ArrayList<>(pushMessageInformations.size()); pushMessageInformations.forEach(pushMessageInformation -> { final PushApplication pushApplication = pushApplicationDao.findByPushApplicationID(pushMessageInformation.getPushApplicationId()); // make sure this is really there, and has not been deleted if (pushApplication != null) { final String applicationName = pushApplication.getName(); final Application application = new Application(applicationName, pushMessageInformation.getPushApplicationId(), pushMessageInformation.getSubmitDate()); applications.add(application); } }); return applications; } }
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 void queueMessageVariantForProcessing(@Observes @DispatchToQueue MessageHolderWithTokens msg) { final VariantType variantType = msg.getVariant().getType(); logger.trace("dispatching payload for {} variant type", variantType); final String deduplicationId = String.format("%s-%s", msg.getPushMessageInformation().getId(), msg.getSerialId()); jmsClient.send(msg).withDuplicateDetectionId(deduplicationId).to(selectQueue(variantType)); }
public void queueMessageVariantForProcessing(@Observes @DispatchToQueue MessageHolderWithTokens msg) { final VariantType variantType = msg.getVariant().getType(); logger.trace("dispatching payload for {} variant type", variantType); final String deduplicationId = String.format("%s-%s", msg.getPushMessageInformation().getId(), msg.getSerialId()); jmsClient.send(msg).withDuplicateDetectionId(deduplicationId).to(selectQueue(variantType)); }
/** * 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() ) ); }
/** * 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() ) ); }