private void recordFutureNotificationFromTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final DateTime effectiveDate, final NotificationEvent notificationKey, final InternalCallContext context) { try { final NotificationQueue subscriptionEventQueue = notificationQueueService.getNotificationQueue(KILLBILL_SERVICES.SUBSCRIPTION_BASE_SERVICE.getServiceName(), DefaultSubscriptionBaseService.NOTIFICATION_QUEUE_NAME); subscriptionEventQueue.recordFutureNotificationFromTransaction(entitySqlDaoWrapperFactory.getHandle().getConnection(), effectiveDate, notificationKey, context.getUserToken(), context.getAccountRecordId(), context.getTenantRecordId()); } catch (final NoSuchNotificationQueue e) { throw new RuntimeException(e); } catch (final IOException e) { throw new RuntimeException(e); } }
@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) { if (!(inputKey instanceof SubscriptionNotificationKey)) { log.error("SubscriptionBase service received an unexpected event className='{}'", inputKey.getClass().getName()); return; } final SubscriptionNotificationKey key = (SubscriptionNotificationKey) inputKey; final SubscriptionBaseEvent event = dao.getEventById(key.getEventId(), internalCallContextFactory.createInternalTenantContext(tenantRecordId, accountRecordId)); if (event == null) { // This can be expected if the event is soft deleted (is_active = 0) log.debug("Failed to extract event for notification key {}", inputKey); return; } final InternalCallContext context = internalCallContextFactory.createInternalCallContext(tenantRecordId, accountRecordId, "SubscriptionEventQueue", CallOrigin.INTERNAL, UserType.SYSTEM, fromNotificationQueueUserToken); processEventReady(event, key.getSeqId(), context); } }; subscriptionEventQueue = notificationQueueService.createNotificationQueue(KILLBILL_SERVICES.SUBSCRIPTION_BASE_SERVICE.getServiceName(), NOTIFICATION_QUEUE_NAME, queueHandler); } catch (final NotificationQueueAlreadyExists e) { throw new RuntimeException(e); } }
@Override public void triggerNodeCommand(final NodeCommand nodeCommand, final boolean localNodeOnly) { final String event; try { event = mapper.serializeNodeCommand(nodeCommand.getNodeCommandMetadata()); broadcastApi.broadcast(KILLBILL_SERVICES.BROADCAST_SERVICE.getServiceName(), nodeCommand.getNodeCommandType(), event, clock.getUTCNow(), "unset", localNodeOnly); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
@Override public String getName() { return KILLBILL_SERVICES.OVERDUE_SERVICE.getServiceName(); }
@Override public String getName() { return KILLBILL_SERVICES.BROADCAST_SERVICE.getServiceName(); }
private void recordFutureNotificationFromTransaction(final EntitySqlDaoWrapperFactory transactionalDao, final DateTime effectiveDate, final NotificationEvent notificationKey, final InternalCallContext context) { try { final NotificationQueue subscriptionEventQueue = notificationQueueService.getNotificationQueue(KILLBILL_SERVICES.SUBSCRIPTION_BASE_SERVICE.getServiceName(), 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); } }
private int getPendingNotificationCnt(final InternalCallContext internalCallContext) { try { return Iterables.size(notificationQueueService.getNotificationQueue(KILLBILL_SERVICES.PAYMENT_SERVICE.getServiceName(), Janitor.QUEUE_NAME).getFutureOrInProcessingNotificationForSearchKeys(internalCallContext.getAccountRecordId(), internalCallContext.getTenantRecordId())); } catch (final Exception e) { fail("Test failed ", e); } // Not reached.. return -1; } }
private void recordFutureNotificationFromTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final DateTime effectiveDate, final NotificationEvent notificationKey, final InternalCallContext context) { try { final NotificationQueue subscriptionEventQueue = notificationQueueService.getNotificationQueue(KILLBILL_SERVICES.SUBSCRIPTION_BASE_SERVICE.getServiceName(), DefaultSubscriptionBaseService.NOTIFICATION_QUEUE_NAME); subscriptionEventQueue.recordFutureNotificationFromTransaction(entitySqlDaoWrapperFactory.getHandle().getConnection(), effectiveDate, notificationKey, context.getUserToken(), context.getAccountRecordId(), context.getTenantRecordId()); } catch (final NoSuchNotificationQueue e) { throw new RuntimeException(e); } catch (final IOException e) { throw new RuntimeException(e); } }
@Override public void triggerNodeCommand(final NodeCommand nodeCommand, final boolean localNodeOnly) { final String event; try { event = mapper.serializeNodeCommand(nodeCommand.getNodeCommandMetadata()); broadcastApi.broadcast(KILLBILL_SERVICES.BROADCAST_SERVICE.getServiceName(), nodeCommand.getNodeCommandType(), event, clock.getUTCNow(), "unset", localNodeOnly); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
@Override public String getName() { return KILLBILL_SERVICES.SUBSCRIPTION_BASE_SERVICE.getServiceName(); }
@Override public String getName() { return KILLBILL_SERVICES.TENANT_SERVICE.getServiceName(); }
@Override public String getName() { return KILLBILL_SERVICES.CATALOG_SERVICE.getServiceName(); }
@Override public String getName() { return KILLBILL_SERVICES.ACCOUNT_SERVICE.getServiceName(); }
@Override public String getName() { return KILLBILL_SERVICES.CONFIG_SERVICE.getServiceName(); }
@Override public String getName() { return KILLBILL_SERVICES.SECURITY_SERVICE.getServiceName(); }
@Override public String getName() { return KILLBILL_SERVICES.BROADCAST_SERVICE.getServiceName(); }
@Override public String getName() { return KILLBILL_SERVICES.NODES_SERVICE.getServiceName() ; }
@Override public String getName() { return KILLBILL_SERVICES.OVERDUE_SERVICE.getServiceName(); }
@Override public String getName() { return KILLBILL_SERVICES.CURRENCY_SERVICE.getServiceName(); }
private void recordFutureNotificationFromTransaction(final EntitySqlDaoWrapperFactory transactionalDao, final DateTime effectiveDate, final NotificationEvent notificationKey, final InternalCallContext context) { try { final NotificationQueue subscriptionEventQueue = notificationQueueService.getNotificationQueue(KILLBILL_SERVICES.SUBSCRIPTION_BASE_SERVICE.getServiceName(), 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); } }