Simple WLST script to add WebLogic Cluster timer scheduler

0

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.

About Author

Started in pharmacy, I made the change to IT in 1996. I am an Oracle Fusion Middleware Architect at AMIS, with focus on technical infrastructure, Serverside solutions, installing, administering, configuring the Oracle Fusion Middleware stack. My experience is from integrations at telco´s using Oracle AIA, Oracle Portal, OID, Forms&Reports, Discoverer upto the latest Oracle WebLogic 11g releases with practically all Oracle products running on top of it

Leave a Reply