use of org.killbill.billing.overdue.notification.OverdueAsyncBusNotificationKey in project killbill by killbill.
the class OverdueListener method insertBusEventIntoNotificationQueue.
private void insertBusEventIntoNotificationQueue(final UUID accountId, final OverdueAsyncBusNotificationAction action, final InternalCallContext callContext) {
final boolean shouldInsertNotification = shouldInsertNotification(callContext);
if (shouldInsertNotification) {
OverdueAsyncBusNotificationKey notificationKey = new OverdueAsyncBusNotificationKey(accountId, action);
asyncPoster.insertOverdueNotification(accountId, clock.getUTCNow(), OverdueAsyncBusNotifier.OVERDUE_ASYNC_BUS_NOTIFIER_QUEUE, notificationKey, callContext);
try {
final List<Account> childrenAccounts = accountApi.getChildrenAccounts(accountId, callContext);
if (childrenAccounts != null) {
for (Account childAccount : childrenAccounts) {
if (childAccount.isPaymentDelegatedToParent()) {
final InternalTenantContext internalTenantContext = internalCallContextFactory.createInternalTenantContext(childAccount.getId(), callContext);
final InternalCallContext accountContext = internalCallContextFactory.createInternalCallContext(internalTenantContext.getAccountRecordId(), callContext);
notificationKey = new OverdueAsyncBusNotificationKey(childAccount.getId(), action);
asyncPoster.insertOverdueNotification(childAccount.getId(), clock.getUTCNow(), OverdueAsyncBusNotifier.OVERDUE_ASYNC_BUS_NOTIFIER_QUEUE, notificationKey, accountContext);
}
}
}
} catch (Exception e) {
log.error("Error loading child accounts from account " + accountId);
}
}
}
Aggregations