use of password.pwm.util.localdb.WorkQueueProcessor in project pwm by pwm-project.
the class EmailService method init.
public void init(final PwmApplication pwmApplication) throws PwmException {
status = STATUS.OPENING;
this.pwmApplication = pwmApplication;
servers.addAll(EmailServerUtil.makeEmailServersMap(pwmApplication.getConfig()));
for (final EmailServer emailServer : servers) {
serverErrors.put(emailServer, Optional.empty());
}
serverIncrementer = new AtomicLoopIntIncrementer(servers.size() - 1);
if (pwmApplication.getLocalDB() == null || pwmApplication.getLocalDB().status() != LocalDB.Status.OPEN) {
LOGGER.warn("localdb is not open, EmailService will remain closed");
status = STATUS.CLOSED;
return;
}
final WorkQueueProcessor.Settings settings = WorkQueueProcessor.Settings.builder().maxEvents(Integer.parseInt(pwmApplication.getConfig().readAppProperty(AppProperty.QUEUE_EMAIL_MAX_COUNT))).retryDiscardAge(new TimeDuration(pwmApplication.getConfig().readSettingAsLong(PwmSetting.EMAIL_MAX_QUEUE_AGE), TimeUnit.SECONDS)).retryInterval(new TimeDuration(Long.parseLong(pwmApplication.getConfig().readAppProperty(AppProperty.QUEUE_EMAIL_RETRY_TIMEOUT_MS)))).preThreads(Integer.parseInt(pwmApplication.getConfig().readAppProperty(AppProperty.QUEUE_EMAIL_MAX_THREADS))).build();
final LocalDBStoredQueue localDBStoredQueue = LocalDBStoredQueue.createLocalDBStoredQueue(pwmApplication, pwmApplication.getLocalDB(), LocalDB.DB.EMAIL_QUEUE);
workQueueProcessor = new WorkQueueProcessor<>(pwmApplication, localDBStoredQueue, settings, new EmailItemProcessor(), this.getClass());
status = STATUS.OPEN;
}
use of password.pwm.util.localdb.WorkQueueProcessor in project pwm by pwm-project.
the class SmsQueueManager method init.
public void init(final PwmApplication pwmApplication) throws PwmException {
status = STATUS.OPENING;
this.pwmApplication = pwmApplication;
if (pwmApplication.getLocalDB() == null || pwmApplication.getLocalDB().status() != LocalDB.Status.OPEN) {
LOGGER.warn("localdb is not open, will remain closed");
status = STATUS.CLOSED;
return;
}
final WorkQueueProcessor.Settings settings = WorkQueueProcessor.Settings.builder().maxEvents(Integer.parseInt(pwmApplication.getConfig().readAppProperty(AppProperty.QUEUE_SMS_MAX_COUNT))).retryDiscardAge(new TimeDuration(pwmApplication.getConfig().readSettingAsLong(PwmSetting.SMS_MAX_QUEUE_AGE), TimeUnit.SECONDS)).retryInterval(new TimeDuration(Long.parseLong(pwmApplication.getConfig().readAppProperty(AppProperty.QUEUE_SMS_RETRY_TIMEOUT_MS)))).build();
final LocalDBStoredQueue localDBStoredQueue = LocalDBStoredQueue.createLocalDBStoredQueue(pwmApplication, pwmApplication.getLocalDB(), LocalDB.DB.SMS_QUEUE);
workQueueProcessor = new WorkQueueProcessor<>(pwmApplication, localDBStoredQueue, settings, new SmsItemProcessor(), this.getClass());
smsSendEngine = new SmsSendEngine(pwmApplication, pwmApplication.getConfig());
status = STATUS.OPEN;
}
Aggregations