Saturday 15 March 2014

Batch scheduling in weblogic

Hi Every one today i have time to explain about BatchProcess in WebLogic we need to perform following steps
=>Create java class as follows....
public class SchedulerStartupServlet extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html; charset=UTF-8";

    public void init(ServletConfig config) throws ServletException {          
        super.init(config);
     
    }
   
    public void startScheduler(ServletConfig config) {

        try {
         
         String cronexp = "0 0 21 1/1 * ? *";    //this cron expression will be set at 9pm if any other timings go //www.cronmaker.com it will generate the cronexps.
         


            JobDetail job =
                JobBuilder.newJob(ADF.class).withIdentity("ADFJob", "ADFGroupOne").build();
         
            Trigger trigger =
                TriggerBuilder.newTrigger().withIdentity("ADFTrigger", "ADFTriggerGroupOne").withSchedule(CronScheduleBuilder.cronSchedule(cronexp)).build();
       
           
            Scheduler scheduler = new StdSchedulerFactory().getScheduler();
            scheduler.start();
            scheduler.scheduleJob(job, trigger);
              } catch (SchedulerException se) {
            se.printStackTrace();
        }
    }
}
==>create one more java class as follows.
import java.util.Date;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class ADF implements Job {
    public ADF() {
        super();
    }

    public void execute(JobExecutionContext context) throws JobExecutionException {
        try {
            this.JobSheetProcessing();
        } catch (Exceptions e) {
            e.printStackTrace();
        }
    }

    public void JobSheetProcessing() throws Exceptions{
       //write your logic to call or run  the batchjob
     
               }
}

==>The following jar are required
->c3p0-0.9.1.1.jar
->log4j-1.2.16.jar
->quartz-2.2.1.jar
->quartz-jobs-2.2.1.jar
->slf4j-api-1.6.6.jar
->slf4j-log4j12-1.6.6.jar
download add to libraries and class path of the view controller run the project.........


1 comment: