on 08-17-2012 7:40 AM
Hi,
I have following problem:
I created a new job. No problems so far. I can see it in the job definitions and a can create tasks manually in the NW adm.
Now I tried to add a task programmatically.
This is my message driven bean:
@MessageDriven(
activationConfig = {
@ActivationConfigProperty(
propertyName = "messageSelector", propertyValue = "JobDefinition='NewSchedulerJob'"
),
@ActivationConfigProperty(
propertyName = "destinationType", propertyValue = "javax.jms.Queue"
) })
public class SchedulerJobBean extends MDBJobImplementation {
private static final Location loc = Location.getLocation(Location.getLocation("com.hbas.service.bean"));
public void onJob(JobContext ctx) {
Logger log = ctx.getLogger();
//Obtain a JNDI reference to the scheduler
Scheduler scheduler;
Context init_ctx;
try {
init_ctx = new InitialContext();
scheduler = (Scheduler)init_ctx.lookup("scheduler");
SchedulerRemote sessionBeanBean = (SchedulerRemote) init_ctx.lookup("sap.com/some_app/REMOTE/SchedulerBean/some_appRemote");
String value = sessionBeanBean.getResult("1234567890");
log.info("The status of the unit is: " + value);
} catch (NamingException e) {
e.printStackTrace();
return;
}
//Get the Job definition by name
//as defined in the job-definition.xml
JobDefinition jobDef = scheduler.getJobDefinitionByName("NewSchedulerJob");
// Create SchedulerTime instance for one minute in the future
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 1);
Date date = calendar.getTime();
//Create SchedulerTime and pass to it the Calendar instance
SchedulerTime time = new SchedulerTime(date, TimeZone.getDefault());
//Create RecurringEntry and pass to it SchedulerTime instance
RecurringEntry[] re = { new RecurringEntry(time) };
//Create a SchedulerTask for the Job
SchedulerTask task = SchedulerTask.createSchedulerTask(jobDef.getJobDefinitionId(), null, re, null, null, -2, "NewSchedulerJob", "Get the result", null);
//Schedule the task
try {
scheduler.schedule(task);
} catch (TaskValidationException e) {
SimpleLogger.log(Severity.ERROR, Category.SYS_SERVER, loc, "api:ab0200", "Scheduler error " + e );
return;
}
return;
}
And my job-definition
<?xml version="1.0" encoding="UTF-8"?>
<job-definitions>
<job-definition name="NewSchedulerJob" description="Log and calc string">
</job-definition>
</job-definitions>
But after the deployment I can't see a new task.
Any suggestions?
No one?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.