use of org.killbill.notificationq.api.NotificationQueueService.NotificationQueueHandler in project killbill by killbill.
the class BaseRetryService method initialize.
@Override
public void initialize() throws NotificationQueueAlreadyExists {
retryQueue = notificationQueueService.createNotificationQueue(DefaultPaymentService.SERVICE_NAME, 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, paymentRetryService, CallOrigin.INTERNAL, UserType.SYSTEM, userToken);
retryPaymentTransaction(key.getAttemptId(), key.getPaymentControlPluginNames(), callContext);
}
});
}
use of org.killbill.notificationq.api.NotificationQueueService.NotificationQueueHandler in project killbill by killbill.
the class DefaultOverdueNotifierBase method initialize.
@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);
}
}
use of org.killbill.notificationq.api.NotificationQueueService.NotificationQueueHandler in project killbill by killbill.
the class DefaultEntitlementService method initialize.
@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 CallContext callContext = internalCallContextFactory.createCallContext(internalCallContext);
processEntitlementNotification((EntitlementNotificationKey) inputKey, internalCallContext, callContext);
} else if (inputKey instanceof BlockingTransitionNotificationKey) {
processBlockingNotification((BlockingTransitionNotificationKey) inputKey, internalCallContext);
} else if (inputKey != null) {
log.error("Entitlement service received an unexpected event className='{}", 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);
}
}
use of org.killbill.notificationq.api.NotificationQueueService.NotificationQueueHandler in project killbill by killbill.
the class DefaultNextBillingDateNotifier method initialize.
@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;
try {
final SubscriptionBase subscription = subscriptionApi.getSubscriptionFromId(key.getUuidKey(), callContextFactory.createInternalTenantContext(tenantRecordId, accountRecordId));
if (subscription == null) {
log.warn("Unable to retrieve subscriptionId='{}' for event {}", key.getUuidKey(), key);
return;
}
if (// Just to ensure compatibility with json that might not have that field (old versions < 0.13.6)
key.isDryRunForInvoiceNotification() != null && key.isDryRunForInvoiceNotification()) {
processEventForInvoiceNotification(key.getUuidKey(), targetDate, userToken, accountRecordId, tenantRecordId);
} else {
processEventForInvoiceGeneration(key.getUuidKey(), targetDate, userToken, accountRecordId, tenantRecordId);
}
} catch (SubscriptionBaseApiException e) {
log.warn("Error retrieving subscriptionId='{}'", key.getUuidKey(), e);
}
}
};
nextBillingQueue = notificationQueueService.createNotificationQueue(DefaultInvoiceService.INVOICE_SERVICE_NAME, NEXT_BILLING_DATE_NOTIFIER_QUEUE, notificationQueueHandler);
}
use of org.killbill.notificationq.api.NotificationQueueService.NotificationQueueHandler in project killbill by killbill.
the class ParentInvoiceCommitmentNotifier method initialize.
@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 ParentInvoiceCommitmentNotificationKey)) {
log.error("Invoice service received an unexpected event type {}", notificationKey.getClass().getName());
return;
}
final ParentInvoiceCommitmentNotificationKey key = (ParentInvoiceCommitmentNotificationKey) notificationKey;
listener.handleParentInvoiceCommitmentEvent(key.getUuidKey(), userToken, accountRecordId, tenantRecordId);
} catch (IllegalArgumentException e) {
log.error("The key returned from the ParentInvoiceCommitmentQueue is not a valid UUID", e);
}
}
};
commitInvoiceQueue = notificationQueueService.createNotificationQueue(DefaultInvoiceService.INVOICE_SERVICE_NAME, PARENT_INVOICE_COMMITMENT_NOTIFIER_QUEUE, notificationQueueHandler);
}
Aggregations