Skip to content

Commit

Permalink
JBPM-6430 - Refactor priority support for Asynchronous Tasks (#1009)
Browse files Browse the repository at this point in the history
  • Loading branch information
mswiderski committed Oct 4, 2017
1 parent f44f436 commit 07ae3e3
Showing 1 changed file with 11 additions and 7 deletions.
Expand Up @@ -82,6 +82,10 @@ public class ExecutorImpl implements Executor {

private static final Logger logger = LoggerFactory.getLogger(ExecutorImpl.class);

private static final int DEFAULT_PRIORITY = 5;
private static final int MAX_PRIORITY = 9;
private static final int MIN_PRIORITY = 0;

private ExecutorStoreService executorStoreService;

private List<ScheduledFuture<?>> handle = new ArrayList<ScheduledFuture<?>>();
Expand Down Expand Up @@ -343,16 +347,16 @@ public Long scheduleRequest(String commandId, Date date, CommandContext ctx) {
} else {
requestInfo.setRetries(retries);
}
int priority = 5;
int priority = DEFAULT_PRIORITY;
if (ctx.getData("priority") != null) {
priority = (Integer) ctx.getData("priority");
if (priority < 0) {
logger.warn("Priority {} is not valid (cannot be less than 0) setting it to 0", priority);
priority = 0;
if (priority < MIN_PRIORITY) {
logger.warn("Priority {} is not valid (cannot be less than {}) setting it to {}", MIN_PRIORITY, MIN_PRIORITY, priority);
priority = MIN_PRIORITY;

} else if (priority > 9) {
logger.warn("Priority {} is not valid (cannot be more than 9) setting it to 9", priority);
priority = 9;
} else if (priority > MAX_PRIORITY) {
logger.warn("Priority {} is not valid (cannot be more than {}) setting it to {}", MAX_PRIORITY, MAX_PRIORITY, priority);
priority = MAX_PRIORITY;
}

}
Expand Down

0 comments on commit 07ae3e3

Please sign in to comment.