diff --git a/invoice/src/main/java/com/ning/billing/invoice/notification/DefaultNextBillingDateNotifier.java b/invoice/src/main/java/com/ning/billing/invoice/notification/DefaultNextBillingDateNotifier.java
index 5c03f01..99e4f28 100644
--- a/invoice/src/main/java/com/ning/billing/invoice/notification/DefaultNextBillingDateNotifier.java
+++ b/invoice/src/main/java/com/ning/billing/invoice/notification/DefaultNextBillingDateNotifier.java
@@ -38,7 +38,6 @@ import com.ning.billing.util.notificationq.NotificationQueueService.Notification
import com.ning.billing.util.notificationq.NotificationQueueService.NotificationQueueHandler;
public class DefaultNextBillingDateNotifier implements NextBillingDateNotifier {
-
private static final Logger log = LoggerFactory.getLogger(DefaultNextBillingDateNotifier.class);
public static final String NEXT_BILLING_DATE_NOTIFIER_QUEUE = "next-billing-date-queue";
@@ -47,13 +46,12 @@ public class DefaultNextBillingDateNotifier implements NextBillingDateNotifier {
private final InvoiceConfig config;
private final EntitlementUserApi entitlementUserApi;
-
private NotificationQueue nextBillingQueue;
private final InvoiceListener listener;
@Inject
public DefaultNextBillingDateNotifier(final NotificationQueueService notificationQueueService,
- final InvoiceConfig config, final EntitlementUserApi entitlementUserApi, final InvoiceListener listener) {
+ final InvoiceConfig config, final EntitlementUserApi entitlementUserApi, final InvoiceListener listener) {
this.notificationQueueService = notificationQueueService;
this.config = config;
this.entitlementUserApi = entitlementUserApi;
@@ -62,17 +60,27 @@ public class DefaultNextBillingDateNotifier implements NextBillingDateNotifier {
@Override
public void initialize() throws NotificationQueueAlreadyExists {
- nextBillingQueue = notificationQueueService.createNotificationQueue(DefaultInvoiceService.INVOICE_SERVICE_NAME,
- NEXT_BILLING_DATE_NOTIFIER_QUEUE,
- new NotificationQueueHandler() {
+ final NotificationConfig notificationConfig = new NotificationConfig() {
+ @Override
+ public long getSleepTimeMs() {
+ return config.getSleepTimeMs();
+ }
+
+ @Override
+ public boolean isNotificationProcessingOff() {
+ return config.isNotificationProcessingOff();
+ }
+ };
+
+ final NotificationQueueHandler notificationQueueHandler = new NotificationQueueHandler() {
@Override
public void handleReadyNotification(final NotificationKey notificationKey, final DateTime eventDate) {
try {
-
- if (! (notificationKey instanceof NextBillingDateNotificationKey)) {
+ if (!(notificationKey instanceof NextBillingDateNotificationKey)) {
log.error("Invoice service received an unexpected event type {}", notificationKey.getClass().getName());
return;
}
+
final NextBillingDateNotificationKey key = (NextBillingDateNotificationKey) notificationKey;
try {
final Subscription subscription = entitlementUserApi.getSubscriptionFromId(key.getUuidKey());
@@ -87,23 +95,13 @@ public class DefaultNextBillingDateNotifier implements NextBillingDateNotifier {
} catch (IllegalArgumentException e) {
log.error("The key returned from the NextBillingNotificationQueue is not a valid UUID", e);
}
-
}
- },
- new NotificationConfig() {
-
- @Override
- public long getSleepTimeMs() {
- return config.getSleepTimeMs();
- }
-
- @Override
- public boolean isNotificationProcessingOff() {
- return config.isNotificationProcessingOff();
- }
- }
- );
+ };
+ nextBillingQueue = notificationQueueService.createNotificationQueue(DefaultInvoiceService.INVOICE_SERVICE_NAME,
+ NEXT_BILLING_DATE_NOTIFIER_QUEUE,
+ notificationQueueHandler,
+ notificationConfig);
}
@Override
@@ -122,6 +120,4 @@ public class DefaultNextBillingDateNotifier implements NextBillingDateNotifier {
private void processEvent(final UUID subscriptionId, final DateTime eventDateTime) {
listener.handleNextBillingDateEvent(subscriptionId, eventDateTime);
}
-
-
}
diff --git a/overdue/src/main/java/com/ning/billing/ovedue/notification/DefaultOverdueCheckNotifier.java b/overdue/src/main/java/com/ning/billing/ovedue/notification/DefaultOverdueCheckNotifier.java
index 0d58473..cf51e2b 100644
--- a/overdue/src/main/java/com/ning/billing/ovedue/notification/DefaultOverdueCheckNotifier.java
+++ b/overdue/src/main/java/com/ning/billing/ovedue/notification/DefaultOverdueCheckNotifier.java
@@ -35,20 +35,19 @@ import com.ning.billing.util.notificationq.NotificationQueueService.Notification
import com.ning.billing.util.notificationq.NotificationQueueService.NotificationQueueHandler;
public class DefaultOverdueCheckNotifier implements OverdueCheckNotifier {
-
private static final Logger log = LoggerFactory.getLogger(DefaultOverdueCheckNotifier.class);
public static final String OVERDUE_CHECK_NOTIFIER_QUEUE = "overdue-check-queue";
private final NotificationQueueService notificationQueueService;
private final OverdueProperties config;
+ private final OverdueListener listener;
private NotificationQueue overdueQueue;
- private final OverdueListener listener;
@Inject
- public DefaultOverdueCheckNotifier(final NotificationQueueService notificationQueueService,
- final OverdueProperties config, final OverdueListener listener) {
+ public DefaultOverdueCheckNotifier(final NotificationQueueService notificationQueueService, final OverdueProperties config,
+ final OverdueListener listener) {
this.notificationQueueService = notificationQueueService;
this.config = config;
this.listener = listener;
@@ -56,38 +55,41 @@ public class DefaultOverdueCheckNotifier implements OverdueCheckNotifier {
@Override
public void initialize() {
- try {
- overdueQueue = notificationQueueService.createNotificationQueue(DefaultOverdueService.OVERDUE_SERVICE_NAME,
- OVERDUE_CHECK_NOTIFIER_QUEUE,
- new NotificationQueueHandler() {
- @Override
- public void handleReadyNotification(final NotificationKey notificationKey, final DateTime eventDate) {
- try {
- if (! (notificationKey instanceof OverdueCheckNotificationKey)) {
- log.error("Overdue service received Unexpected notificationKey {}", notificationKey.getClass().getName());
- return;
- }
- final OverdueCheckNotificationKey key = (OverdueCheckNotificationKey) notificationKey;
- processEvent(key.getUuidKey(), eventDate);
- } catch (IllegalArgumentException e) {
- log.error("The key returned from the NextBillingNotificationQueue is not a valid UUID", e);
+ final NotificationConfig notificationConfig = new NotificationConfig() {
+ @Override
+ public boolean isNotificationProcessingOff() {
+ return config.isNotificationProcessingOff();
+ }
+
+ @Override
+ public long getSleepTimeMs() {
+ return config.getSleepTimeMs();
+ }
+ };
+
+ final NotificationQueueHandler notificationQueueHandler = new NotificationQueueHandler() {
+ @Override
+ public void handleReadyNotification(final NotificationKey notificationKey, final DateTime eventDate) {
+ try {
+ if (!(notificationKey instanceof OverdueCheckNotificationKey)) {
+ log.error("Overdue service received Unexpected notificationKey {}", notificationKey.getClass().getName());
return;
}
- }
- },
- new NotificationConfig() {
- @Override
- public boolean isNotificationProcessingOff() {
- return config.isNotificationProcessingOff();
+ final OverdueCheckNotificationKey key = (OverdueCheckNotificationKey) notificationKey;
+ processEvent(key.getUuidKey(), eventDate);
+ } catch (IllegalArgumentException e) {
+ log.error("The key returned from the NextBillingNotificationQueue is not a valid UUID", e);
}
- @Override
- public long getSleepTimeMs() {
- return config.getSleepTimeMs();
- }
}
- );
+ };
+
+ try {
+ overdueQueue = notificationQueueService.createNotificationQueue(DefaultOverdueService.OVERDUE_SERVICE_NAME,
+ OVERDUE_CHECK_NOTIFIER_QUEUE,
+ notificationQueueHandler,
+ notificationConfig);
} catch (NotificationQueueAlreadyExists e) {
throw new RuntimeException(e);
}
@@ -113,6 +115,4 @@ public class DefaultOverdueCheckNotifier implements OverdueCheckNotifier {
private void processEvent(final UUID overdueableId, final DateTime eventDateTime) {
listener.handleNextOverdueCheck(overdueableId);
}
-
-
}