Skip to content

Instantly share code, notes, and snippets.

@mariomartinezricston
Created September 20, 2016 12:56
Show Gist options
  • Save mariomartinezricston/c3d33b4b415ca126cb1ee5e948405ae1 to your computer and use it in GitHub Desktop.
Save mariomartinezricston/c3d33b4b415ca126cb1ee5e948405ae1 to your computer and use it in GitHub Desktop.
Schedule 1 day delay
public void scheduleOneDay(final MuleEventContext eventContext) {
String status=eventContext.getMessage().getInvocationProperty("processStatus");
//runnable for logging and executing
final Runnable callFlow = createRunnableLauncher(eventContext);
//Schedule call in the next day
if(status.equals(InvoiceIntegrationUtils.STATUS_WAIT)){
int delayInMinutes=InvoiceIntegrationUtils.addOneDayDelay();
printNextSchedule(delayInMinutes);
scheduler.schedule(callFlow, delayInMinutes, TimeUnit.MINUTES);
}
}
private Runnable createRunnableLauncher(final MuleEventContext eventContext) {
final Runnable callFlow = new Runnable() {
public void run() {
logger.info("Scheduled executor: Run Invoice process");
try {
eventContext.getMuleContext().getClient().dispatch(InvoiceIntegrationUtils.STARTUP_ENDPOINT, eventContext.getMessage());
} catch (MuleException e) {
e.printStackTrace();
}
}
};
return callFlow;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment