Oracle Service Bus: WLST Fundamentals

Oracle Service Bus: WLST Fundamentals

Gepubliceerd: Categorie: Oracle

In my series of blogs about the Oracle Service Bus and WLST scripting I’d like to focus some more on the fundamentals, which will guide you through building smart generic scripts for your OSB/WebLogic domain. As you might know, WebLogic uses the WLST build on Python and Jython for getting tasks programmatically standardized and, if necessary, automated. Now, before you start using WLST together with Oracle Service Bus, it may be useful to understand some fundamentals.

Just as the MBeans in a standard WebLogic Domain, Oracle Service Bus uses its own MBeans on top of it. You can use this to request specific information about the configuration, resources such as proxy and business services. You also can export and import a certain configuration like you do in the Service Bus Console.

When you want to create a WLST script for some purpose, the following MBeans are the most important to start with:

  • SessionManagementBean: Used to create, save or discard a session, the same way as in the console. For doing this you can use the following methods:
  1. Creates the session ( can also be multiple )
  2. Commit your changes
  3. Rollback your changes before activate
  4. Exit when actions are done or rollbacked.
  1. createSession()
  2. activateSession()
  3. discardSession()
  4. sessionExists()

These actions you normally do in the console using these buttons:

  • ALSBConfgurationMBean: For the import and export of OSB configurations, updating specific information such as endpoint URI’s, and investigate configurations and resources. With this MBean you can manage your OSB configuration, which, packaged in a JAR file, can be Proxy and BusinessServices, WSDL’s or other resources.
  • ServiceDomainMBean: This MBean finds any service enabled for monitoring, and get or reset statistics for services which are enabled for monitoring.

When you start WLST, standard WebLogic modules are loaded but specific OSB you should import in your script to use are:

  1. from import ALSBConfigurationMBean
  2. from com.bea.wli.monitoring import ServiceDomainMBean

to be found in com.bea.common.configfwk_1.5.0.0.jar, sb-kernel-api.jar and sb-kernel-impl.jar in your OSB library home.

Creating the session:

  1. sessionManager = findService(SessionManagementMBean.NAME, SessionManagementMBean.TYPE)
  2. sessionManager.createSession(sessionName)

Then do some stuff….

And save the session or discard when something went wrong:

  1. # Activate the change session
  2. print 'Activating my session...'
  3. sessionManager.activateSession(sessionName, 'Doing stuff session activated')
  4. except:
  5. if sessionManager != None:
  6. sessionManager.discardSession(sessionName)
  7. raise

Use of resource references

For the identification of projects, folders and other resources you can use the Ref() class, and you will use it with the ALSBConfgurationMBean. You can create, delete or export projects and folders with the following methods:

  1. createProject(Ref project, String Description)
  2. createFolder(Ref folder, String Description)
  3. delete()
  4. importUploaded(ALSBImportPlan plan) to implement a customization plan
  5. Customize(List customizations)
  6. ExportProjects(Collection Refs, String.

Normally it’s done through this section in the sbconsole:

Below you see a snippet of how to import a Customization (with the customization stored in an XML file):

  1. from import SessionManagementMBean
  2. from import ALSBConfigurationMBean
  3. from com.bea.wli.config import Ref ..
  4. sessionName = createSessionName()
  5. print 'Created session', sessionName
  6. SessionMBean = getSessionMBean(sessionName)
  7. print 'SessionMBean started session'
  8. ALSBConfigurationMBean = findService(String("ALSBConfiguration.").concat(sessionName), "")
  9. print "ALSBConfiguration MBean found", ALSBConfigurationMBean
  10. #customize if a customization file is specified
  11. #affects only the created resources
  12. if customFile != None :
  13. print 'Loading customization File', customFile
  14. iStream = FileInputStream(customFile)
  15. customizationList = Customization.fromXML(iStream)
  16. for customization in customizationList:
  17. print '\n customization', customization.getDescription()
  18. print customizationList.size()
  19. ALSBConfigurationMBean.customize(customizationList)
  20. print 'Customization applied'
  21. SessionMBean.commitSession(sessionName)
  22. print 'session committed'
  23. except:
  24. print "Unexpected error:", sys.exc_info()[0]
  25. if SessionMBean != None:
  26. SessionMBean.discardSession(sessionName)
  27. raise

… and so on.


Through this interface you can get loads of statistics of your services. Some of the methods to use are:

  • Determining which services are enabled for monitoring
  1. getMonitoredBusinessServiceRefs()
  2. getMonitoredProxyServiceRefs
  • Gives back runtime statistics collected. You can specify a server name, or get back cluster wide statistics from an aggregated view of statistics of all managed servers).
  1. getBusinessServiceStatistics()
  2. getProxyServiceStatistics()

A short sample below:

  1. stats = cmo.getProxyServiceStatistics([ref],ResourceType.SERVICE.value(),'')
  2. for ps in stats[ref].getAllResourceStatistics():
  3. for s in ps.getStatistics():
  4. if s.getType() == StatisticType.COUNT:
  5. print s.getName() + "("+ str(s.getType()) +"): " + str(s.getCount())
  6. if s.getType() == StatisticType.INTERVAL:
  7. print ( s.getName() + "("+ str(s.getType()) +"): " + str(s.getMin()) + " " + str(s.getMax()) + " " + str(s.getAverage()) + " " + str(s.getSum())
  8. if s.getType() == StatisticType.STATUS:
  9. print s.getName() + "("+ str(s.getType()) +"): " + str(s.getCurrentStatus()) + "(" + str(s.getInitialStatus()) + ")"

Now, these are some basics to help you build your own customized and nifty scripts, have fun and good luck with it!

Michel Schildmeijer
Over auteur Michel Schildmeijer

Having started in the pharmacy sector, Michel transitioned to IT in 1996, where he worked on a UNIX TTY terminal-based system and the MUMPS language. He currently works as a solutions architect at Qualogy, with a focus on middleware, application integration and service-oriented architecture. His passion for middleware started in 2000, when he worked as a support analyst in the financial sector with BEA WebLogic and Tuxedo. Michel is an expert on the WebLogic platform. He serves customers in his role as architect and advises them in all aspects of their IT landscape. He became an Oracle ACE in 2012 and wrote two books about WebLogic: Oracle WebLogic Server 11gR1 PS2: Administration Essentials and Oracle WebLogic Server 12c: First Look. He is a well-known speaker at national and international conferences and is recognized as an official Oracle Speaker. Since a few years, he is also an active contributor to the OpenSource community and solutions regarding containerization and DevOps. Furthermore, he is a well-known expert in several communities. He speaks regularly at events in the EMEA region and worldwide, such as KubeCon, Continuous Delivery Summit, Oracle OpenWorld, Groundbreakers Developers Tours and several other tech conferences. Read more at: and

Meer posts van Michel Schildmeijer
Reacties (1)
  1. om 03:03

    Very good article. I need help on creating JNDI Providers using WLST. Can you please give me sample script to do that.? Thanks in advanced

Reactie plaatsen