@Override public void initialize() throws NotificationQueueAlreadyExists { final NotificationQueueHandler notificationQueueHandler = new NotificationQueueHandler() { @Override public void handleReadyNotification(final NotificationEvent notificationKey, final DateTime eventDate, final UUID userToken, final Long accountRecordId, final Long tenantRecordId) { try { if (!(notificationKey instanceof NextBillingDateNotificationKey)) { log.error("Invoice service received an unexpected event type {}", notificationKey.getClass().getName()); return; } final NextBillingDateNotificationKey key = (NextBillingDateNotificationKey) notificationKey; try { final SubscriptionBase subscription = subscriptionApi.getSubscriptionFromId(key.getUuidKey(), callContextFactory.createInternalTenantContext(tenantRecordId, accountRecordId)); if (subscription == null) { log.warn("Next Billing Date Notification Queue handled spurious notification (key: " + key + ")"); } else { processEvent(key.getUuidKey(), eventDate, userToken, accountRecordId, tenantRecordId); } } catch (SubscriptionBaseApiException e) { log.warn("Next Billing Date Notification Queue handled spurious notification (key: " + key + ")", e); } } catch (IllegalArgumentException e) { log.error("The key returned from the NextBillingNotificationQueue is not a valid UUID", e); } } }; nextBillingQueue = notificationQueueService.createNotificationQueue(DefaultInvoiceService.INVOICE_SERVICE_NAME, NEXT_BILLING_DATE_NOTIFIER_QUEUE, notificationQueueHandler); }
@Override public void initialize(final String svcName) throws NotificationQueueAlreadyExists { retryQueue = notificationQueueService.createNotificationQueue(svcName, getQueueName(), new NotificationQueueHandler() { @Override public void handleReadyNotification(final NotificationEvent notificationKey, final DateTime eventDateTime, final UUID userToken, final Long accountRecordId, final Long tenantRecordId) { if (!(notificationKey instanceof PaymentRetryNotificationKey)) { log.error("Payment service got an unexpected notification type {}", notificationKey.getClass().getName()); return; } final PaymentRetryNotificationKey key = (PaymentRetryNotificationKey) notificationKey; final InternalCallContext callContext = internalCallContextFactory.createInternalCallContext(tenantRecordId, accountRecordId, PAYMENT_RETRY_SERVICE, CallOrigin.INTERNAL, UserType.SYSTEM, userToken); retry(key.getUuidKey(), callContext); } }); }
@Override public void initialize() { final OverdueNotifier myself = this; final NotificationQueueHandler notificationQueueHandler = new NotificationQueueHandler() { @Override public void handleReadyNotification(final NotificationEvent notificationKey, final DateTime eventDate, final UUID userToken, final Long accountRecordId, final Long tenantRecordId) { myself.handleReadyNotification(notificationKey, eventDate, userToken, accountRecordId, tenantRecordId); } }; try { overdueQueue = notificationQueueService.createNotificationQueue(DefaultOverdueService.OVERDUE_SERVICE_NAME, getQueueName(), notificationQueueHandler); } catch (NotificationQueueAlreadyExists e) { throw new RuntimeException(e); } }
@LifecycleHandlerType(LifecycleLevel.INIT_SERVICE) public void initialize() { try { final NotificationQueueHandler queueHandler = new NotificationQueueHandler() { @Override public void handleReadyNotification(final NotificationEvent inputKey, final DateTime eventDateTime, final UUID fromNotificationQueueUserToken, final Long accountRecordId, final Long tenantRecordId) { final InternalCallContext internalCallContext = internalCallContextFactory.createInternalCallContext(tenantRecordId, accountRecordId, "EntitlementQueue", CallOrigin.INTERNAL, UserType.SYSTEM, fromNotificationQueueUserToken); if (inputKey instanceof EntitlementNotificationKey) { final UUID tenantId = nonEntityDao.retrieveIdFromObject(tenantRecordId, ObjectType.TENANT); processEntitlementNotification((EntitlementNotificationKey) inputKey, tenantId, internalCallContext); } else if (inputKey instanceof BlockingTransitionNotificationKey) { processBlockingNotification((BlockingTransitionNotificationKey) inputKey, internalCallContext); } else if (inputKey != null) { log.error("Entitlement service received an unexpected event type {}" + inputKey.getClass()); } else { log.error("Entitlement service received an unexpected null event"); } } }; entitlementEventQueue = notificationQueueService.createNotificationQueue(ENTITLEMENT_SERVICE_NAME, NOTIFICATION_QUEUE_NAME, queueHandler); } catch (final NotificationQueueAlreadyExists e) { throw new RuntimeException(e); } }
final Map<NotificationEvent, Boolean> expectedNotifications = new TreeMap<NotificationEvent, Boolean>(); final NotificationQueue queue = queueService.createNotificationQueue("test-svc", "many", new NotificationQueueHandler() {
final Map<NotificationEvent, Boolean> expectedNotificationsBarney = new TreeMap<NotificationEvent, Boolean>(); final NotificationQueue queueFred = queueService.createNotificationQueue("UtilTest", "Fred", new NotificationQueueHandler() { @Override public void handleReadyNotification(final NotificationEvent eventJson, final DateTime eventDateTime, final UUID userToken, final Long searchKey1, final Long searchKey2) { final NotificationQueue queueBarney = queueService.createNotificationQueue("UtilTest", "Barney", new NotificationQueueHandler() { @Override public void handleReadyNotification(final NotificationEvent eventJson, final DateTime eventDateTime, final UUID userToken, final Long searchKey1, final Long searchKey2) {
final NotificationQueue queue = queueService.createNotificationQueue("test-svc", "foo", new NotificationQueueHandler() {