quratz - dynamically pass parameters to the job

First pass in the parameters before running :

The getJobDataMap() method of the JobDetail class returns the value JobDataMap, on which the Map operation can be performed.

E.g:

job.getJobDataMap().put("love", "I love you very much!");

 

 

Second, get the parameters in the job :

In the execute method, pass in the context context as follows:

public void execute(JobExecutionContext context)

Then get the JobDataMap and get the required data from the Map. The sample code is as follows:

String jobName = context.getJobDetail().getName();

JobDataMap dataMap = context.getJobDetail (). GetJobDataMap ();

String strData = dataMap.getString("love");

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326713488&siteId=291194637