Skip to content

Instantly share code, notes, and snippets.

@anatollupacescu
Last active November 30, 2017 13:22
Show Gist options
  • Save anatollupacescu/924bb63326e4f6d845bdc8be772149ed to your computer and use it in GitHub Desktop.
Save anatollupacescu/924bb63326e4f6d845bdc8be772149ed to your computer and use it in GitHub Desktop.

Your autowire both jobs:

@Autowired
private Job procesaClientesJob;

@Autowired
private Job procesaParcialClientesJob;

Your web annotated method would look like this:

@GetMapping("/invokejob/{processType}/{strFecha}")
public String invokejob(@PathVariable String processType, @PathVariable String strFecha) throws Exception {

And the code calling the job would look like this:

JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).addDate("fecha", fecha).toJobParameters();
if ("full".equals(processType) {
	jobLauncher.run(procesaClientesJob, jobParameters);
} else {
	jobLauncher.run(procesaParcialClientesJob, jobParameters);
}

And then you call the method like this

curl -v localhost:8080/invokeJob/full/fetchaNotSureWhatThisIs to fire the "full" job and

curl -v localhost:8080/invokeJob/parcial/thisEither to fire the "parcial" job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment