[Version 5.0.1 and later]Recreating Scheduler tasks

Before you begin

This step requires advanced knowledge of developing J2EE Applications and the Scheduler programming interfaces.

Steps for this task

  1. Use the administrative console to locate each Scheduler resource that was used in WebSphere Application Server Version 5.0. For each Scheduler resource, note the JNDI name.
  2. Back up the Scheduler database.
  3. Create a new or modify an existing EJB or servlet J2EE application to implement as a method that you intend to use as the Scheduler update program.
  4. Create a method similar to the included example.
    This action finds all existing Scheduler tasks, deletes them and creates new ones with the same parameters. If Global Security is enabled in the WebSphere Application Server and the "security" context is enabled on the WorkManager referenced by the Scheduler resource, the current security context is used (as well all other J2EE contexts that are enabled on the creating EJB or servlet thread). See the following as an example:
    public void recreateTasks(String schedulerJNDIName)
            throws Exception
        {
            InitialContext ctx = new InitialContext();
            Scheduler s = (Scheduler)ctx.lookup(schedulerJNDIName);
    
            Iterator tasks = null;;
            try
            {
                tasks = s.findTasksByName("%");
            }
            catch (SchedulerNotAvailableException e)
            {
                e.printStackTrace();
                throw e;
            }
            
            // Iterate through each task and recreate it.
            while(tasks.hasNext())
            {
                TaskInfo curTask = (TaskInfo) tasks.next();
    
                int retries=0;
                boolean deleted=false;
                TaskStatus status=null;
                
                // It's best to include each cancel/create
                // in it's own transaction (not shown here).
                while(!deleted && retries < 5)
                {
                    try
                    {
                        // Delete the task.
                        s.cancel(curTask.getTaskId(), true);
                        deleted = true;
                        
                        // Create a new one.
                        int createRetries = 0;
                        boolean created = false;
                        while(!created && createRetries<5)
                        {
                            try
                            {
                                s.create(curTask);
                                created = true;
                            }
                            catch (Exception e)
                            {
                                ++createRetries;
                                Thread.sleep(5000);
                            }
                        }
                        if (!created)
                        {
                            System.out.println("Task Not Created: " + curTask.getTaskId());
                        }
                    }
                    catch (Exception se)
                    {
                        ++retries;
                        Thread.sleep(5000);
                    }
                }
                if (!deleted)
                {
                    System.out.println("Task Not Deleted: " + curTask.getTaskId());
                }
            }
        }    
    

Related tasks
Deleting Scheduler tasks
Recreating Scheduler tables



Searchable topic ID:   tschrecreatetasks
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/scheduler/tasks/tsch_recreatetasks.html

Library | Support | Terms of Use | Feedback