I have this old Quartz job which I would like to migrate to a new version:
@Component
public class SystemProcessJob implements Job {
......
@Override
protected void execute(JobExecutionContext context) throws JobExecutionException
{
final JobKey key = context.getJobDetail().getKey();
final UUID runId = UUID.fromString(key.getName());
executeInternalProcess(runId);
logger.info("Job Executed");
}
When I run it I get error:
java.lang.IllegalArgumentException: Invalid UUID string: jobDetail
What should be the proper way to migrate this code? I need to generate manual UUID runId or get the UUID rom the job?
You are getting the IllegalArgumentException because UUID.fromString is expecting you to provide a real UUID which should look like "24b7cc4e-a3ba-4ee7-b0e3-1ccdda09ec30" 32 digit hexadecimal number check, it is getting "jobDetail" as UUID and throwing the exception.
Without knowing the full context of the project. If you want to use a UUID as the job identifier in Quartz, you should ensure that you're setting the job name to a valid UUID string when you're creating the job. Here's an example of how you can do this:
now the method below will bring the UUID as you wanted
I do not know the how the UUID is used in
executeInternalProcesspersonally I would use onlyUUID.randomUUID()instead ofUUID.fromStringthis will lower the complexity, And if you do not see any problems you don't need to create that job at the beginning with the random UUID.