Simple WLST script to add WebLogic Cluster timer scheduler

Share this on .. Tweet about this on TwitterShare on LinkedIn0Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page

It seems like an easy task to do within WebLogic Admin Console, but sometimes an administrator requires automation. WebLogic Server can schedule future tasks similar to a scheduled job. It works by using the class that will execute the task and metadata to a database.  One cluster member will be responsible for JobScheduler which invokes the Timertask.  The server responsible for this service will check the database every xx secs to see if there are new tasks .

To setup the Timer you will need a datasource and table name for the timer ( default name WebLogic uses is weblogic_timers) That section is not covered inhere, but just a simple script to set up the timer

## Created by M. Schildmeijer
## WLST Script to configure the WebLogic Scheduler Table name and DataSource
## Replace anything between <> with your own WebLogic Server values
## Properties Section
user='weblogic'
pw='<password weblogic admin>'
adminServer='<AdminServer Host>'
adminPort='<Admin Port>'
clusterName='<cluster name>'
jsschedtblnm='<job scheduler table name>'
dsname='<DataSource Name>'
## Standard Connection creation
try:
  connect(user,pw,'t3://'+adminServer+':'+adminPort)
except:
  print 'Error connecting to Admin Server'
## Get the list of managed servers in the cluster
try:
  domainConfig()
  cd('Clusters/'+clusterName)
  managedServers=cmo.getServers()
  print 'Found ' + ' managed servers' + managedServers
except:
  print 'Error navigating DomainConfig MBean tree for the list of managed servers'
  ## Start an edit session and navigate
domainConfig()
edit()
startEdit()
cd('/Clusters/' +clusterName)
cmo.setJobSchedulerTableName(jsschedtblnm)
save()
cd('/Clusters/' +clusterName +'/' +'setDataSourceForJobScheduler' )
cmo.setDataSourceForJobScheduler(dsname)
save()
activate() 
Share this on .. Tweet about this on TwitterShare on LinkedIn0Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page