Pages

Tuesday, July 3, 2012

Do WebLogic configuration from ANT

With WebLogic WLST you can script the creation of all your Application DataSources or SOA Integration artifacts( like JMS etc). This is necessary if your domain contains many WebLogic artifacts or you have more then one WebLogic environment. If so, you want to script this so you can configure a  new WebLogic domain in minutes and you can repeat this task with always the same result.

I started a new project on Github https://github.com/biemond/soa_tools/tree/master/ant_wls which can do this from ANT, for this I created some WLST ANT macrodefs. These ANT targets can be invoked many times ( great for Continuous Integration ) and if the object already exists it rollbacks the edit action and give a BeanAlreadyExists exception. Great way to keep all your environments in sync.

These ANT scripts can do the following configuration.

  • Create users and roles
  • Reset or create JDBC DataSources 
  • File or JDBC persistence stores
  • JMS servers
  • JMS modules
  •    Sub Deployments
  •    Foreign Servers
  •       Foreign Server Destinations
  •       Foreign Server Connection Factories
  •    Connection Factories
  •    Queues ( Distributed )
  •    Topics ( Distributed )
  •    SAF Remote Contexts
  •    SAF Imported Destinations 
  • SAF agents 

Still to do  is the creation of SAF Imported Destinations.   

An example of an ANT macrodef with the WLST code for the creation of a Queue or a Topic on a WebLogic server or cluster, also supports distributed Queue or Topics plus re-directing to an other Queue.



Snippet of the ANT build.xml with the ANT target which calls this Macrodef and uses the build.properties for all the JMS objects definitions. The foreach is provided by the ANT Contrib library, this is not part of ANT and need to downloaded separately .


Snippet of the build.properties with all the weblogic environments. Just change wls.environment to acc or   some other value.

wls.environment=dev

# dev deployment server weblogic
dev.serverURL=t3://localhost:7001
dev.user=weblogic
dev.password=weblogic1
dev.target=AdminServer

# acceptance deployment server weblogic
acc.serverURL=t3://soaps3:7001
acc.user=weblogic
acc.password=weblogic1
acc.target=soa_server1



# All jms objects entries like Queue, Topic or distributed
queuesOrTopics=error1,queue1

# JMS module name
error1.jmsModule=JMSModule1
# JMS module subdeployment.
error1.subDeployment=JmsServer
error1.jmsName=ErrorQueue      
error1.jmsJNDIName=jms/ErrorQueue
# queue, topic
error1.jmsType=queue
# distributed true ,false
error1.distributed=false
error1.balancingPolicy=xxxxx
# redirect to an error Queue
error1.redirect=false
error1.limit=xxxxx
error1.policy=xxxxx      
error1.errorObject=xxxxx

queue1.jmsModule=JMSModule1
queue1.subDeployment=JmsServer
queue1.jmsName=Queue1      
queue1.jmsJNDIName=jms/Queue1
queue1.jmsType=queue
queue1.distributed=false
queue1.balancingPolicy=xxxxx
queue1.redirect=true
queue1.limit=3
queue1.policy=Redirect
queue1.errorObject=ErrorQueue

And we can run the ANT target when we execute the following command.

ant -f build.xml createCreateJMSQueuesOrTopics


https://github.com/biemond/soa_tools/tree/master/ant_wls