Search in sources :

Example 11 with NoSuchNotificationQueue

use of org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue in project killbill by killbill.

the class MockSubscriptionDaoMemory method recordFutureNotificationFromTransaction.

private void recordFutureNotificationFromTransaction(final EntitySqlDaoWrapperFactory transactionalDao, final DateTime effectiveDate, final NotificationEvent notificationKey, final InternalCallContext context) {
    try {
        final NotificationQueue subscriptionEventQueue = notificationQueueService.getNotificationQueue(DefaultSubscriptionBaseService.SUBSCRIPTION_SERVICE_NAME, DefaultSubscriptionBaseService.NOTIFICATION_QUEUE_NAME);
        subscriptionEventQueue.recordFutureNotificationFromTransaction(null, effectiveDate, notificationKey, 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 12 with NoSuchNotificationQueue

use of org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue 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 13 with NoSuchNotificationQueue

use of org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue 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 14 with NoSuchNotificationQueue

use of org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue 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)

Example 15 with NoSuchNotificationQueue

use of org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue in project killbill by killbill.

the class PushNotificationListener method saveRetryPushNotificationInQueue.

private void saveRetryPushNotificationInQueue(final UUID tenantId, final String url, final NotificationJson notificationJson, final int attemptRetryNumber) {
    final PushNotificationKey key = new PushNotificationKey(tenantId, notificationJson.getAccountId() != null ? UUID.fromString(notificationJson.getAccountId()) : null, notificationJson.getEventType(), notificationJson.getObjectType(), notificationJson.getObjectId() != null ? UUID.fromString(notificationJson.getObjectId()) : null, attemptRetryNumber + 1, url);
    final TenantContext tenantContext = contextFactory.createTenantContext(tenantId);
    final DateTime nextNotificationTime = getNextNotificationTime(key.getAttemptNumber(), internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(tenantContext));
    if (nextNotificationTime == null) {
        log.warn("Max attempt number reached for push notification url='{}', tenantId='{}'", key.getUrl(), key.getTenantId());
        return;
    }
    log.debug("Push notification is scheduled to send at {} for url='{}', tenantId='{}'", nextNotificationTime, key.getUrl(), key.getTenantId());
    final Long accountRecordId = internalCallContextFactory.getRecordIdFromObject(key.getAccountId(), ObjectType.ACCOUNT, tenantContext);
    final Long tenantRecordId = internalCallContextFactory.getRecordIdFromObject(key.getTenantId(), ObjectType.TENANT, tenantContext);
    try {
        final NotificationQueue notificationQueue = notificationQueueService.getNotificationQueue(DefaultServerService.SERVER_SERVICE, PushNotificationRetryService.QUEUE_NAME);
        notificationQueue.recordFutureNotification(nextNotificationTime, key, null, MoreObjects.firstNonNull(accountRecordId, new Long(0)), tenantRecordId);
    } catch (NoSuchNotificationQueue noSuchNotificationQueue) {
        log.error("Failed to push notification url='{}', tenantId='{}'", key.getUrl(), key.getTenantId(), noSuchNotificationQueue);
    } catch (IOException e) {
        log.error("Failed to push notification url='{}', tenantId='{}'", key.getUrl(), key.getTenantId(), e);
    }
}
Also used : NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue) InternalTenantContext(org.killbill.billing.callcontext.InternalTenantContext) TenantContext(org.killbill.billing.util.callcontext.TenantContext) NotificationQueue(org.killbill.notificationq.api.NotificationQueue) NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue) IOException(java.io.IOException) DateTime(org.joda.time.DateTime)

Aggregations

NotificationQueue (org.killbill.notificationq.api.NotificationQueue)15 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)3 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 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 TenantContext (org.killbill.billing.util.callcontext.TenantContext)1