Created
September 20, 2016 12:56
-
-
Save mariomartinezricston/c3d33b4b415ca126cb1ee5e948405ae1 to your computer and use it in GitHub Desktop.
Schedule 1 day delay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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