@Override public int getReadyNotificationEntriesForSearchKey1(Long searchKey1) { return ((NotificationSqlDao) dao.getSqlDao()).getCountReadyEntries(searchKey1, clock.getUTCNow().toDate(), config.getTableName(), "search_key1"); }
@Override public int getReadyNotificationEntriesForSearchKey2(Long searchKey2) { return ((NotificationSqlDao) dao.getSqlDao()).getCountReadyEntries(searchKey2, clock.getUTCNow().toDate(), config.getTableName(), "search_key2"); }
this.nbProcessedEvents = new AtomicLong(); final NotificationSqlDao sqlDao = (dbi != null) ? dbi.onDemand(NotificationSqlDao.class) : null; this.dao = new DBBackedQueue<NotificationEventModelDao>(clock, sqlDao, config, "notif-" + config.getTableName(), metricRegistry);
@Override public void removeNotificationFromTransaction(final Transmogrifier transmogrifier, final Long recordId) { final NotificationSqlDao transactional = transmogrifier.become(NotificationSqlDao.class); final NotificationEventModelDao existing = transactional.getByRecordId(recordId, config.getTableName()); final NotificationEventModelDao removedEntry = new NotificationEventModelDao(existing, Hostname.get(), clock.getUTCNow(), PersistentQueueEntryLifecycleState.REMOVED); dao.moveEntryToHistoryFromTransaction(transactional, removedEntry); }
@Override public void removeNotification(final Long recordId) { final NotificationEventModelDao existing = dao.getSqlDao().getByRecordId(recordId, config.getTableName()); final NotificationEventModelDao removedEntry = new NotificationEventModelDao(existing, Hostname.get(), clock.getUTCNow(), PersistentQueueEntryLifecycleState.REMOVED); dao.moveEntryToHistory(removedEntry); }
private <T extends NotificationEvent> List<NotificationEventWithMetadata<T>> getFutureNotificationsInternal(final Class<T> typeX, final NotificationSqlDao transactionalDao, final String searchKey, final Long searchKeyValue) { final List<NotificationEventWithMetadata<T>> result = new LinkedList<NotificationEventWithMetadata<T>>(); final List<NotificationEventModelDao> entries = transactionalDao.getReadyQueueEntriesForSearchKey(getFullQName(), searchKeyValue, config.getTableName(), searchKey); for (NotificationEventModelDao cur : entries) { final T event = (T) DefaultQueueLifecycle.deserializeEvent(cur.getClassName(), objectMapper, cur.getEventJson()); final NotificationEventWithMetadata<T> foo = new NotificationEventWithMetadata<T>(cur.getRecordId(), cur.getUserToken(), cur.getCreatedDate(), cur.getSearchKey1(), cur.getSearchKey2(), event, cur.getFutureUserToken(), cur.getEffectiveDate(), cur.getQueueName()); result.add(foo); } return result; }
UUID.randomUUID(), effDt, "testBasic"); dao.insertEntry(notif, notificationQueueConfig.getTableName()); final List<NotificationEventModelDao> notifications = dao.getReadyEntries(now.toDate(), hostname, 3, notificationQueueConfig.getTableName()); assertNotNull(notifications); assertEquals(notifications.size(), 1); final int res = dao.claimEntry(notification.getRecordId(), now.toDate(), ownerId, nextAvailable.toDate(), notificationQueueConfig.getTableName()); assertEquals(res, 1); dao.claimEntry(notification.getRecordId(), now.toDate(), ownerId, nextAvailable.toDate(), notificationQueueConfig.getTableName()); notification = dao.getByRecordId(notification.getRecordId(), notificationQueueConfig.getTableName()); assertEquals(notification.getEventJson(), eventJson); validateDate(notification.getEffectiveDate(), effDt); validateDate(notificationHistory.getNextAvailableDate(), processedTime); dao.removeEntry(notification.getRecordId(), notificationQueueConfig.getTableName()); notification = dao.getByRecordId(notification.getRecordId(), notificationQueueConfig.getTableName()); assertNull(notification);