@Override public void stop() throws NoSuchNotificationQueue { if (nextBillingQueue != null) { nextBillingQueue.stopQueue(); notificationQueueService.deleteNotificationQueue(nextBillingQueue.getServiceName(), nextBillingQueue.getQueueName()); } }
@Override public void stopQueue() { // Order matters... isStarted = false; notificationQueueService.stopQueue(); }
@Override public void startQueue() { notificationQueueService.startQueue(); isStarted = true; }
private void recordFutureNotification(final DateTime effectiveDate, final NotificationEvent notificationEvent, final InternalCallContext context) { try { final NotificationQueue subscriptionEventQueue = notificationQueueService.getNotificationQueue(DefaultEntitlementService.ENTITLEMENT_SERVICE_NAME, DefaultEntitlementService.NOTIFICATION_QUEUE_NAME); subscriptionEventQueue.recordFutureNotification(effectiveDate, notificationEvent, context.getUserToken(), context.getAccountRecordId(), context.getTenantRecordId()); } catch (NoSuchNotificationQueue e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } }
private void recordFutureNotificationFromTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> transactionalDao, final DateTime effectiveDate, final NotificationEvent notificationKey, final InternalCallContext context) { try { final NotificationQueue subscriptionEventQueue = notificationQueueService.getNotificationQueue(DefaultSubscriptionBaseService.SUBSCRIPTION_SERVICE_NAME, DefaultSubscriptionBaseService.NOTIFICATION_QUEUE_NAME); subscriptionEventQueue.recordFutureNotificationFromTransaction(null, effectiveDate, notificationKey, context.getUserToken(), context.getAccountRecordId(), context.getTenantRecordId()); } catch (NoSuchNotificationQueue e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void start() { retryQueue.startQueue(); }
@Override public Object inTransaction(final DummySqlTest transactional, final TransactionStatus status) throws Exception { queue.recordFutureNotificationFromTransaction(transactional, now.plus((currentIteration + 1) * nextReadyTimeIncrementMs), eventJson, TOKEN_ID, SEARCH_KEY_1, SEARCH_KEY_2); return null; } });
protected NotificationQueueHandler getHandlerForActiveQueue(final String compositeName) { synchronized (queues) { final NotificationQueue queue = queues.get(compositeName); if (queue == null || !queue.isStarted()) { return null; } return queue.getHandler(); } }
@Override public Void inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception { final Collection<NotificationEventWithMetadata<T>> futureNotifications = getFutureNotificationsForAccountInTransaction(entitySqlDaoWrapperFactory, checkOverdueQueue, accountId, clazz, context); for (final NotificationEventWithMetadata<T> notification : futureNotifications) { checkOverdueQueue.removeNotificationFromTransaction(entitySqlDaoWrapperFactory.getSqlDao(), notification.getRecordId()); } return null; } });
@Override public boolean apply(@Nullable final NotificationQueue input) { return input.getReadyNotificationEntriesForSearchKey2(tenantRecordId) > 0; } });
@Override public void stop() throws NoSuchNotificationQueue { if (retryQueue != null) { retryQueue.stopQueue(); notificationQueueService.deleteNotificationQueue(retryQueue.getServiceName(), retryQueue.getQueueName()); } }
private void recordFutureNotification(final DateTime effectiveDate, final NotificationEvent notificationEvent, final InternalCallContext context) { try { final NotificationQueue subscriptionEventQueue = notificationQueueService.getNotificationQueue(DefaultEntitlementService.ENTITLEMENT_SERVICE_NAME, DefaultEntitlementService.NOTIFICATION_QUEUE_NAME); subscriptionEventQueue.recordFutureNotification(effectiveDate, notificationEvent, context.getUserToken(), context.getAccountRecordId(), context.getTenantRecordId()); } catch (NoSuchNotificationQueue e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } }
@Override public void start() { overdueQueue.startQueue(); }
@Override public Object inTransaction(final DummySqlTest transactional, final TransactionStatus status) throws Exception { queue.recordFutureNotificationFromTransaction(transactional, readyTime, eventJson, TOKEN_ID, SEARCH_KEY_1, SEARCH_KEY_2); log.info("Posted key: " + eventJson); return null; } });
@Override public void stop() { if (overdueQueue != null) { overdueQueue.stopQueue(); try { notificationQueueService.deleteNotificationQueue(overdueQueue.getServiceName(), overdueQueue.getQueueName()); } catch (NoSuchNotificationQueue e) { log.error("Error deleting a queue by its own name - this should never happen", e); } } }
private void recordPauseResumeNotificationEntry(final UUID entitlementId, final UUID bundleId, final DateTime effectiveDate, final boolean isPause, final InternalCallContext contextWithValidAccountRecordId) throws EntitlementApiException { final NotificationEvent notificationEvent = new EntitlementNotificationKey(entitlementId, bundleId, isPause ? EntitlementNotificationKeyAction.PAUSE : EntitlementNotificationKeyAction.RESUME, effectiveDate); try { final NotificationQueue subscriptionEventQueue = notificationQueueService.getNotificationQueue(DefaultEntitlementService.ENTITLEMENT_SERVICE_NAME, DefaultEntitlementService.NOTIFICATION_QUEUE_NAME); subscriptionEventQueue.recordFutureNotification(effectiveDate, notificationEvent, contextWithValidAccountRecordId.getUserToken(), contextWithValidAccountRecordId.getAccountRecordId(), contextWithValidAccountRecordId.getTenantRecordId()); } catch (final NoSuchNotificationQueue e) { throw new EntitlementApiException(e, ErrorCode.__UNKNOWN_ERROR_CODE); } catch (final IOException e) { throw new EntitlementApiException(e, ErrorCode.__UNKNOWN_ERROR_CODE); } }
@Override public void start() { nextBillingQueue.startQueue(); }
@Override public Object inTransaction(final DummySqlTest transactional, final TransactionStatus status) throws Exception { queueFred.recordFutureNotificationFromTransaction(transactional, readyTime, eventJsonFred, TOKEN_ID, SEARCH_KEY_1, SEARCH_KEY_2); log.info("posted key: " + eventJsonFred.toString()); queueBarney.recordFutureNotificationFromTransaction(transactional, readyTime, eventJsonBarney, TOKEN_ID, SEARCH_KEY_1, SEARCH_KEY_2); log.info("posted key: " + eventJsonBarney.toString()); return null; } });
@LifecycleHandlerType(LifecycleLevel.STOP_SERVICE) public void stop() throws NoSuchNotificationQueue { if (entitlementEventQueue != null) { entitlementEventQueue.stopQueue(); notificationQueueService.deleteNotificationQueue(entitlementEventQueue.getServiceName(), entitlementEventQueue.getQueueName()); } } }
@LifecycleHandlerType(LifecycleLevel.START_SERVICE) public void start() { entitlementEventQueue.startQueue(); }