大家好,我想使用石英安排消息发送。但我真的不知道怎么做。我可以向给定的手机发送消息,但要安排它很困难。我正在尝试的是
1)我正在从用户(JobSchedule.jsp)那里获取消息,手机号码,期间
2) 我正在调用 Jobscheduler Servlet (JobSchdeduleServlet.java) .. 在这里我不知道如何将变量传递给类 (TestJob.java)
// JobSchdeduleServlet.java ..
//specify the job's details..
JobDetail job = JobBuilder.newJob(TestJob.class)
.withIdentity("testJob")
.build();
// SimpleScheduleBuilder.simpleSchedule()
// .withIntervalInSeconds(120);
// specify the running period of the job
int count=Integer.parseInt(request.getParameter("count"));
int hours= Integer.parseInt(request.getParameter("Period"));
request.getSession().setAttribute("nmo", request.getParameter("mobNo"));
request.getSession().setAttribute("msg", request.getParameter("tskMsg"));
String msg=request.getParameter("tskMsg");
String mbno=request.getParameter("mobNo");
Trigger trigger = TriggerBuilder.newTrigger()
.withSchedule(
SimpleScheduleBuilder
.repeatHourlyForTotalCount(count, hours))
.build();
//schedule the job
SchedulerFactory schFactory = new StdSchedulerFactory();
Scheduler sch = schFactory.getScheduler();
sch.start();
sch.scheduleJob(job, trigger);
3)从那个servlet我调用TestJob.java
// TestJob.java
public void execute(JobExecutionContext jExeCtx) throws JobExecutionException {
try {
System.out.println("Printing ......"+jExeCtx);
SendSms.sendSms("9762809280", "Hi");// Here I dont know how to pass user defined mobile no n Message
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
log.debug("TestJob run successfully...");
}
4)在TestJob.java中,我正在调用我的消息发送方法,但我不知道如何传递手机号码和消息?