@LifecycleHandlerType(LifecycleLevel.INIT_SERVICE) public void initialize() { super.initialize("invoice-tag-handler", subscriberQueueHandler); }
@Override public void handleReadyNotification(final NotificationEvent notificationEvent, final DateTime eventDateTime, final UUID userToken, final Long searchKey1, final Long searchKey2) { try { handlerDelegate.handleReadyNotification(notificationEvent, eventDateTime, userToken, searchKey1, searchKey2); } catch (final QueueRetryException e) { // Let the retry queue handle the exception retryableService.scheduleRetry(e, notificationEvent, eventDateTime, userToken, searchKey1, searchKey2, 1); } } }
@LifecycleHandlerType(LifecycleLevel.START_SERVICE) public void start() { super.start(); }
@LifecycleHandlerType(LifecycleLevel.STOP_SERVICE) public void stop() throws NoSuchNotificationQueue { super.stop(); }
public void scheduleRetry(final QueueRetryException exception, final QueueEvent originalNotificationEvent, final DateTime originalEffectiveDate, final UUID userToken, final Long searchKey1, final Long searchKey2, final int retryNb) { final DateTime effectiveDate = computeRetryDate(exception, originalEffectiveDate, retryNb); if (effectiveDate == null) { log.warn("Error processing event, NOT scheduling retry for event='{}', retryNb='{}'", originalNotificationEvent, retryNb, exception); throw new RetryableInternalException(false); } log.warn("Error processing event, scheduling retry for event='{}', effectiveDate='{}', retryNb='{}'", originalNotificationEvent, effectiveDate, retryNb, exception); try { final NotificationEvent retryNotificationEvent = new RetryNotificationEvent(objectMapper.writeValueAsString(originalNotificationEvent), originalNotificationEvent.getClass(), originalEffectiveDate, retryNb); retryNotificationQueue.recordFutureNotification(effectiveDate, retryNotificationEvent, userToken, searchKey1, searchKey2); throw new RetryableInternalException(true); } catch (final IOException e) { log.error("Unable to schedule retry for event='{}', effectiveDate='{}'", originalNotificationEvent, effectiveDate, e); throw new RetryableInternalException(false); } }
@LifecycleHandlerType(LifecycleLevel.STOP_SERVICE) public void stop() throws NoSuchNotificationQueue { super.stop(); }
public void initialize(final NotificationQueue originalQueue, final NotificationQueueHandler originalQueueHandler) { initialize(originalQueue.getQueueName(), originalQueueHandler); }
@Override public void start() { super.start(); nextBillingQueue.startQueue(); }
@Override public void stop() throws NoSuchNotificationQueue { if (nextBillingQueue != null) { nextBillingQueue.stopQueue(); notificationQueueService.deleteNotificationQueue(nextBillingQueue.getServiceName(), nextBillingQueue.getQueueName()); } super.stop(); }
searchKey2); } catch (final QueueRetryException e) { scheduleRetry(e, notificationEvent, retryNotificationEvent.getOriginalEffectiveDate(),
@LifecycleHandlerType(LifecycleLevel.INIT_SERVICE) public void initialize() { super.initialize("invoice-listener", subscriberQueueHandler); }
@LifecycleHandlerType(LifecycleLevel.START_SERVICE) public void start() { super.start(); }
public void initialize() { super.initialize("myEvent-listener", subscriberQueueHandler); }
@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) { if (!(notificationKey instanceof NextBillingDateNotificationKey)) { log.error("Invoice service received an unexpected event className='{}", notificationKey.getClass()); return; } final NextBillingDateNotificationKey key = (NextBillingDateNotificationKey) notificationKey; // Just to ensure compatibility with json that might not have that targetDate field (old versions < 0.13.6) final DateTime targetDate = key.getTargetDate() != null ? key.getTargetDate() : eventDate; final UUID firstSubscriptionId = key.getUuidKeys().iterator().next(); if (key.isDryRunForInvoiceNotification() != null && // Just to ensure compatibility with json that might not have that field (old versions < 0.13.6) key.isDryRunForInvoiceNotification()) { processEventForInvoiceNotification(firstSubscriptionId, targetDate, userToken, accountRecordId, tenantRecordId); } else { final boolean isRescheduled = key.isRescheduled() == Boolean.TRUE; // Handle null value (old versions < 0.19.7) processEventForInvoiceGeneration(firstSubscriptionId, targetDate, isRescheduled, userToken, accountRecordId, tenantRecordId); } } }; final NotificationQueueHandler retryableHandler = new RetryableHandler(clock, this, notificationQueueHandler); nextBillingQueue = notificationQueueService.createNotificationQueue(KILLBILL_SERVICES.INVOICE_SERVICE.getServiceName(), NEXT_BILLING_DATE_NOTIFIER_QUEUE, retryableHandler); super.initialize(nextBillingQueue, notificationQueueHandler); }