/** * If {@link NotificationParams#getMaxRetries()} is greater than * {@link NotificationRetryEvent#getRetryCount()}, saves the message in a queue for further retry */ protected boolean saveForFurtherRetryAttempt(final NotificationRetryEvent notificationRetryEvent) { final long maxRetries = notificationRetryEvent.getNotificationDeliveryContext().getNotificationParams().getMaxRetries(); final long retryCount = notificationRetryEvent.getRetryCount(); final boolean retry = retryCount < maxRetries ? true : false; if (retry) { repository.save(notificationRetryEvent); LOGGER.info("Message {} enqueued to be processed further", notificationRetryEvent.getMessage()); } else { final String endpoint = notificationRetryEvent.getNotificationDeliveryContext().getNotificationParams().getEndpoint(); LOGGER.warn("Push message {} to {} is rejected because the number of maximum retries ({}) has been achieved.", notificationRetryEvent.getMessage(), endpoint, maxRetries); } return retry; }
private SubscriptionMessage parseSubscriptionToSubscribeMessage(final Subscription subscription) { final SubscriptionMessage message = new SubscriptionMessage(); message.setType(subscription.getType().toString()); if (subscription.getNotificationParams() != null) { message.setEndpoint(subscription.getNotificationParams().getEndpoint()); message.setMaxRetries(subscription.getNotificationParams().getMaxRetries()); message.setRetryDelay(subscription.getNotificationParams().getRetryDelay()); } switch (subscription.getType()) { case DATA: message.setProvider(((DataSubscription) subscription).getProviderId()); message.setSensor(((DataSubscription) subscription).getSensorId()); break; case ALARM: message.setAlert(((AlarmSubscription) subscription).getAlertId()); break; case ORDER: message.setProvider(((OrderSubscription) subscription).getOwnerEntityId()); message.setSensor(((OrderSubscription) subscription).getSensorId()); break; } return message; }