Configuring and Managing WebLogic JMS

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Using WLST to Manage JMS Servers and JMS System Module Resources

The WebLogic Scripting Tool (WLST) is a command-line scripting interface that you can use to create and manage JMS servers and JMS system module resources. See “ Using the WebLogic Scripting Tool” and WLST Sample Scripts in the WebLogic Scripting Tool.


Understanding JMS System Modules and Subdeployments

A JMS system module is described by the jms-system-resource MBean in the config.xml file. Basic components of a jms-system-resource MBean are:

The JMS resources of a system module are located in a module descriptor file that conforms to the weblogic-jmsmd.xml schema. In Figure 6-1, the module is named myModule-jms.xml and it contains JMS system resource definitions for a connection factory and a queue. The sub-deployment-name element is used to group and target JMS resources in the myModule-jms.xml file to targets in the config.xml. You have to provide a value for the sub-deployment-name element when using WLST. For more information on subdeployments, see “ JMS System Module and Resource Subdeployment Targeting”. In Figure 6-1, the sub-deployment-name DeployToJMSServer1is used to group and target the connection factory CConfac and the queue CQueue in the myModule-jms module.

For more information on how to use JMS resources, see “ Understanding JMS Resource Configuration” in Configuring and Managing WebLogic JMS.

Figure 6-1 Subdeployment Architecture

Subdeployment Architecture


How to Create JMS Servers and JMS System Module Resources

Basic tasks you need to perform when creating JMS system resources with WLST are:

After you have established an edit session, use the following steps configure JMS servers and system module resources:

  1. Get the WebLogic Server MBean object for the server you want to configure resources. For example:
  2. servermb=getMBean("Servers/examplesServer")
        if servermb is None:
            print '@@@ No server MBean found'
  3. Create your system resource. For example:
  4. jmsMySystemResource = create(myJmsSystemResource,"JMSSystemResource")
  5. Target your system resource to a WebLogic Server instance. For example:
  6. jmsMySystemResource.addTarget(servermb)
  7. Get your system resource object. For example:
  8. theJMSResource = jmsMySystemResource.getJMSResource()
  9. Create resources for the module, such as queues, topics, and connection factories. For example:
  10. connfact1 = theJMSResource.createConnectionFactory(factoryName)
    jmsqueue1 = theJMSResource.createQueue(queueName)
  11. Configure resource attributes. For example:
  12. connfact1.setJNDIName(factoryName)
  13. Create a subdeployment name for system resources . See Understanding JMS System Modules and Subdeployments.For example:
  14. connfact1.setSubDeploymentName('DeployToJMSServer1')
  15. Create a JMS server. For example:
  16. jmsserver1mb = create(jmsServerName,'JMSServer')
  17. Target your JMS server to a WebLogic Server instance. For example:
  18. jmsserver1mb.addTarget(servermb)
  19. Create a subdeployment object using the value you provided for the sub-deployment-name element. This step groups the system resources in module to a sub-deployment element in the config.xml. For example:
  20. subDep1mb = jmsMySystemResource.createSubDeployment('DeployToJMSServer1')
  21. Target the subdeployment to a server resource such as a JMS server instance, WebLogic Server instance, or cluster. For example:
  22. subDep1mb.addTarget(jmsserver1mb)
    Listing 6-1 WLST Script to Create JMS System Resources
    This script starts an edit session, creates a JMS Server,
    targets the jms server to the server WLST is connected to and creates
    a JMS System module with a jms queue and connection factory. The
    jms queues and topics are targeted using sub-deployments.

    import sys
    from java.lang import System

    print "@@@ Starting the script ..."

    myJmsSystemResource = "CapiQueue-jms"
    factoryName = "CConFac"
    jmsServerName = "myJMSServer"
    queueName = "CQueue"

    url = sys.argv[1]
    usr = sys.argv[2]
    password = sys.argv[3]

    connect(usr,password, url)

    //Step 1
        if servermb is None:
            print '@@@ No server MBean found'

        //Step 2
        jmsMySystemResource = create(myJmsSystemResource,"JMSSystemResource")
        //Step 3

        //Step 4
        theJMSResource = jmsMySystemResource.getJMSResource()

        //Step 5
        connfact1 = theJMSResource.createConnectionFactory(factoryName)
        jmsqueue1 = theJMSResource.createQueue(queueName)
        //Step 6

        //Step 7
        //Step 8
        jmsserver1mb = create(jmsServerName,'JMSServer')
        //Step 9

        //Step 10
        subDep1mb = jmsMySystemResource.createSubDeployment('DeployToJMSServer1')
        //Step 11


How to Modify and Monitor JMS Servers and JMS System Module Resources

You can modify or monitor JMS objects and attributes by using the appropriate method available from the MBean.

For more information, see Navigating and Editing MBeans in the WebLogic Scripting Tool.

Listing 6-2 WLST Script to Modify JMS Objects
print '@@@ delete system resource'
jmsMySystemResource = delete("CapiQueue-jms","JMSSystemResource")
print '@@@ delete server'
jmsserver1mb = delete(jmsServerName,'JMSServer')


Best Practices when Using WLST to Configure JMS Resources

This section provides best practices information when using WLST to configure JMS servers and JMS system module resources:

  Back to Top       Previous  Next