Search in sources :

Example 6 with NotificationQueue

use of org.killbill.notificationq.api.NotificationQueue in project killbill by killbill.

the class DefaultOverduePosterBase method clearOverdueCheckNotifications.

@Override
public <T extends OverdueCheckNotificationKey> void clearOverdueCheckNotifications(final UUID accountId, final String overdueQueueName, final Class<T> clazz, final InternalCallContext context) {
    try {
        final NotificationQueue checkOverdueQueue = notificationQueueService.getNotificationQueue(DefaultOverdueService.OVERDUE_SERVICE_NAME, overdueQueueName);
        transactionalSqlDao.execute(new EntitySqlDaoTransactionWrapper<Void>() {

            @Override
            public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
                final Iterable<NotificationEventWithMetadata<T>> futureNotifications = getFutureNotificationsForAccountInTransaction(entitySqlDaoWrapperFactory, checkOverdueQueue, clazz, context);
                for (final NotificationEventWithMetadata<T> notification : futureNotifications) {
                    checkOverdueQueue.removeNotificationFromTransaction(entitySqlDaoWrapperFactory.getHandle().getConnection(), notification.getRecordId());
                }
                return null;
            }
        });
    } catch (final NoSuchNotificationQueue e) {
        log.error("Attempting to clear items from a non-existent queue (DefaultOverdueCheck).", e);
    }
}
Also used : NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue) EntitySqlDaoWrapperFactory(org.killbill.billing.util.entity.dao.EntitySqlDaoWrapperFactory) NotificationEventWithMetadata(org.killbill.notificationq.api.NotificationEventWithMetadata) NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue) NotificationQueue(org.killbill.notificationq.api.NotificationQueue)

Example 7 with NotificationQueue

use of org.killbill.notificationq.api.NotificationQueue in project killbill by killbill.

the class PaymentProcessor method cancelScheduledPaymentTransaction.

public void cancelScheduledPaymentTransaction(final UUID lastPaymentAttemptId, final InternalCallContext internalCallContext) throws PaymentApiException {
    try {
        final NotificationQueue retryQueue = notificationQueueService.getNotificationQueue(DefaultPaymentService.SERVICE_NAME, DefaultRetryService.QUEUE_NAME);
        final Iterable<NotificationEventWithMetadata<NotificationEvent>> notificationEventWithMetadatas = retryQueue.getFutureNotificationForSearchKeys(internalCallContext.getAccountRecordId(), internalCallContext.getTenantRecordId());
        for (final NotificationEventWithMetadata<NotificationEvent> notificationEvent : notificationEventWithMetadatas) {
            if (((PaymentRetryNotificationKey) notificationEvent.getEvent()).getAttemptId().equals(lastPaymentAttemptId)) {
                retryQueue.removeNotification(notificationEvent.getRecordId());
            }
        // Go through all results to close the connection
        }
    } catch (final NoSuchNotificationQueue noSuchNotificationQueue) {
        log.error("ERROR Loading Notification Queue - " + noSuchNotificationQueue.getMessage());
        throw new IllegalStateException(noSuchNotificationQueue);
    }
}
Also used : NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue) NotificationEventWithMetadata(org.killbill.notificationq.api.NotificationEventWithMetadata) NotificationEvent(org.killbill.notificationq.api.NotificationEvent) NotificationQueue(org.killbill.notificationq.api.NotificationQueue) NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue)

Example 8 with NotificationQueue

use of org.killbill.notificationq.api.NotificationQueue in project killbill by killbill.

the class DefaultEntitlement method recordFutureNotification.

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 (final NoSuchNotificationQueue e) {
        throw new RuntimeException(e);
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue) NotificationQueue(org.killbill.notificationq.api.NotificationQueue) NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue) IOException(java.io.IOException)

Example 9 with NotificationQueue

use of org.killbill.notificationq.api.NotificationQueue in project killbill by killbill.

the class DefaultEntitlementService method recordFutureNotification.

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 (final NoSuchNotificationQueue e) {
        throw new RuntimeException(e);
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue) NotificationQueue(org.killbill.notificationq.api.NotificationQueue) NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue) IOException(java.io.IOException)

Example 10 with NotificationQueue

use of org.killbill.notificationq.api.NotificationQueue in project killbill by killbill.

the class DefaultEntitlementInternalApi method recordFutureNotification.

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 (final NoSuchNotificationQueue e) {
        throw new RuntimeException(e);
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue) NotificationQueue(org.killbill.notificationq.api.NotificationQueue) NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue) IOException(java.io.IOException)

Aggregations

NotificationQueue (org.killbill.notificationq.api.NotificationQueue)16 NoSuchNotificationQueue (org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue)15 IOException (java.io.IOException)9 NotificationEventWithMetadata (org.killbill.notificationq.api.NotificationEventWithMetadata)7 DateTime (org.joda.time.DateTime)4 NotificationEvent (org.killbill.notificationq.api.NotificationEvent)3 LocalDate (org.joda.time.LocalDate)2 EntitySqlDaoWrapperFactory (org.killbill.billing.util.entity.dao.EntitySqlDaoWrapperFactory)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 UUID (java.util.UUID)1 Nullable (javax.annotation.Nullable)1 InternalTenantContext (org.killbill.billing.callcontext.InternalTenantContext)1 PlanPhasePriceOverride (org.killbill.billing.catalog.api.PlanPhasePriceOverride)1 NextBillingDateNotificationKey (org.killbill.billing.invoice.notification.NextBillingDateNotificationKey)1 DefaultPaymentAttempt (org.killbill.billing.payment.api.DefaultPaymentAttempt)1 PaymentAttempt (org.killbill.billing.payment.api.PaymentAttempt)1 PaymentAttemptModelDao (org.killbill.billing.payment.dao.PaymentAttemptModelDao)1 PaymentRetryNotificationKey (org.killbill.billing.payment.retry.PaymentRetryNotificationKey)1 SubscriptionBase (org.killbill.billing.subscription.api.SubscriptionBase)1