/** * Handles pending subscription/unsubscription events */ private synchronized void processPendingSubscriptions() { for (PendingSubscription pending : pendingSubscriptionEvents) { TariffSubscription sub = tariffSubscriptionRepo.getSubscription(pending.customer, pending.tariff); if (pending.count > 0) sub.subscribe(pending.count); else if (pending.count < 0) sub.deferredUnsubscribe(-pending.count); } pendingSubscriptionEvents.clear(); }
/** * In this overloaded implementation of the changing subscription function, * Here we just put the tariff we want to change and the whole population is * moved to another random tariff. NOTE: Used only for testing... * * @param tariff */ public void changeSubscription (Tariff tariff, Tariff newTariff, CustomerInfo customer) { TariffSubscription ts = service.getTariffSubscriptionRepo().getSubscription(customer, tariff); int populationCount = ts.getCustomersCommitted(); unsubscribe(ts, populationCount); subscribe(newTariff, populationCount, customer); }