Showing posts with label wlst. Show all posts
Showing posts with label wlst. Show all posts

Monday, July 8, 2013

Create a JMS Destination Key on Weblogic 11g using WSLT

UPDATE: 13/04/2014
The article had been published on CodeProject.

http://www.codeproject.com/Tips/748377/Create-a-JMS-Configuration-on-Oracle-Weblogic-g-us
-------------------------------------------------------------------------------------------

There is another method to create a Server Configuration on Weblogic if you are not using the console, if you want to execute a script with all of your configuration you must know about WSLT.

This model solve problems like deployment on others enviroments like Quality Assurance and Production were you should dont have any permision to access to this console, only the deployer will run the script and install any executable on the server. You should follow the next steps:

1. First go to you Weblogic Home, for example the location of my weblogic installation is:


1:  [root@USER25 bin]# cd /root/Oracle/Middleware/11.1.2.4.0/   

2. Go to the next folder...


1:  [root@USER25 bin]# cd /root/Oracle/Middleware/11.1.2.4.0/wlserver_10.3/server/bin  

3. Open a console and keep in mind you should have running weblogic and the execute:


1:  [root@USER25 bin]# ./setWLSEnv.sh  

4. Running the above command you will have the opportunity to run script on Python and IronPython on your weblogic running, I will show you an script example runs several tasks to create a JMS Server, JMS Module, Queue, Dead Letter Queue and DESTINATION QUEUE that is the object we need for this tutorial, so this the code...

The segment of code we  carry on the next ...


1:    def createDestinationKey(dkname):  
2:        print "createDestinationKey() START"    
3:        cd('/JMSSystemResources/'+moduleName+'/JMSResource/'+moduleName)  
4:        dk1 = create(dkname, "DestinationKey")  
5:        dk1.setProperty("JMSPriority")  
6:        dk1.setKeyType("String")  
7:        dk1.setSortOrder("Descending")  
8:        print "createDestinationKey() END"  

Here we define a part of the XML that is deployed on the server, we pass the property, keytype and sortorder that should be published on Weblogic, this procedure can be executed as a transaction as python script. 


1:            ...  
2:          cd('/JMSSystemResources/'+moduleName+'/JMSResource/'+moduleName)                    
3:            cd('/JMSSystemResources/'+moduleName+'/JMSResource/'+moduleName+'/Queues/'+qname)  
4:            set('DestinationKeys',jarray.array([String(dkName)],String))  
5:          ...  


If you follow the script you will get a declaration of an array on XML, that because if you check Weblogic documentation a Destination Key is an Array of String, so in Python you have to declare your DeclarationKeys as String[], keep in mind that note.
  
5. The comand we need to execute on terminal is:


1:  [root@USER25 bin]# java weblogic.WLST createJmsServer.py  

6. Finally we will see the trace of execution, and veryfing with the Weblogic Console all the script will be create all configuration declarated on python file, this is so much powerfull of course you can create a JNDI or any task that we do over console.

UPDATE 29/05/2016
You could found script uploaded to github on the next link:
https://github.com/osanchezh/weblogicjmsclustered-module  

Best Regards,