Advertisements
RSS

Creating Weblogic JMS components with WLST

01 Dec

The previous post explained the different Weblogic JMS components. As promised I would share some WLST scripts which I use to create the different JMS components as an example.

The example set of scripts exist of 3 files:

  • a generic import.properties file which hold the connection settings
  • JMSCreateInfra.jy which configures the JMS persistent stores, servers, modules and CF
  • JMSCreateQueue.jy which creates a queue and configures redirect
The very basic import.properties
##################################################################
# Weblogic connection parameters                                 #
##################################################################
adminUrl=t3://localhost:7001
importUser=weblogic
importPassword=weblogic1

And the WLST script to configure the Persistent Store, JMS Server, JMS Module and CF on your environment. The script is based upon a Weblogic domain containing a Weblogic cluster with 2 Managed Servers. If you want to use these scripts make sure to change the:

– path for persistent store
– cluster name (rbx_dev_wls_cluster)
– managed server name (rbx_dev_wls_0*)
– persistent store name (FileStore_wls0*)
– jms server name (JmsServer_wls0*)
– jms module name (JmsModuleRubix)
– CF name (ConnFactoryGenericRubix*)
– queue names (SR01.getMyData.*)
– sub deployment name (RBX.myDivision)

Execute the script:  java weblogic.WLST scriptname.jy import.properties

#================================
from java.io import FileInputStream
import sys

#================================
# Generic definitions
#================================

def loadProps(configPropFile):
propInputStream = FileInputStream(configPropFile)
configProps = Properties()
configProps.load(propInputStream)
return configProps

#==========================================================================
# Load properties and connect to Weblogic server
#==========================================================================

importConfigFile = sys.argv[1]
exportConfigProp = loadProps(importConfigFile)
adminUrl = exportConfigProp.get("adminUrl")
importUser = exportConfigProp.get("importUser")
importPassword = exportConfigProp.get("importPassword")

#===============================
# Start the script
#===============================

connect(importUser, importPassword, adminUrl)
edit()
startEdit()

#================================
# Build JMS Filestores
# Filestores store the messages
#================================

cd('/')
cmo.createFileStore('FileStore_wls01')
cd('/FileStores/FileStore_wls01')
cmo.setDirectory('D:/oracle/projects/domains/rbx_dev_domain/filestores')
set('Targets', jarray.array([ObjectName('com.bea:Name=rbx_dev_wls_01,Type=Server')], ObjectName))
cd('/')
cmo.createFileStore('FileStore_wls02')
cd('/FileStores/FileStore_wls02')
cmo.setDirectory('D:/oracle/projects/domains/rbx_dev_domain/filestores')
set('Targets', jarray.array([ObjectName('com.bea:Name=rbx_dev_wls_02,Type=Server')], ObjectName))

#================================
# Build JMS Server(s)
# For every MS in cluster define a JMSserver and target a single MS server
#================================

cd('/')
cmo.createJMSServer('JmsServer_wls01')
cd('/Deployments/JmsServer_wls01')
cmo.setPersistentStore(getMBean('/FileStores/FileStore_wls01'))
set('Targets', jarray.array([ObjectName('com.bea:Name=rbx_dev_wls_01,Type=Server')], ObjectName))

## Threshold (values are default)
# cmo.setBytesThresholdHigh(-1)
# cmo.setBytesThresholdLow(-1)
# cmo.setMessagesThresholdHigh(-1)
# cmo.setMessagesThresholdLow(-1)
## Quotas (values are default, except MaxMsgSize set to 10MB)
# cmo.setBytesMaximum(-1)
# cmo.setMessagesMaximum(-1)
# cmo.setBlockingSendPolicy('FIFO')
cmo.setMaximumMessageSize(10000000)
cd('/Deployments/JmsServer_wls01/JMSMessageLogFile/JmsServer_wls01')
cmo.setRotationType('byTime')
cmo.setRotateLogOnStartup(false)
cmo.setRotationTime('00:00')
cmo.setFileTimeSpan(24)
cmo.setFileCount(30)
cmo.setNumberOfFilesLimited(true)
cmo.setFileName('D:/oracle/projects/domains/rbx_dev_domain/servers/rbx_dev_wls_01/logs/jmsServers/JmsServer_wls01_messages.log')

cd('/')
cmo.createJMSServer('JmsServer_wls02')
cd('/Deployments/JmsServer_wls02')
cmo.setPersistentStore(getMBean('/FileStores/FileStore_wls02'))
set('Targets', jarray.array([ObjectName('com.bea:Name=rbx_dev_wls_02,Type=Server')], ObjectName))
## Threshold (values are default)
# cmo.setBytesThresholdHigh(-1)
# cmo.setBytesThresholdLow(-1)
# cmo.setMessagesThresholdHigh(-1)
# cmo.setMessagesThresholdLow(-1)
## Quotas (values are default, except MsgMaxSize is 10MB)
# cmo.setBytesMaximum(-1)
# cmo.setMessagesMaximum(-1)
# cmo.setBlockingSendPolicy('FIFO')
cmo.setMaximumMessageSize(10000000)
cd('/Deployments/JmsServer_wls02/JMSMessageLogFile/JmsServer_wls02')
cmo.setRotationType('byTime')
cmo.setRotateLogOnStartup(false)
cmo.setRotationTime('00:00')
cmo.setFileTimeSpan(24)
cmo.setFileCount(30)
cmo.setNumberOfFilesLimited(true)
cmo.setFileName('D:/oracle/projects/domains/rbx_dev_domain/servers/rbx_dev_wls_02/logs/jmsServers/JmsServer_wls02_messages.log')

#================================
# Build JMS Module
# target preferrable cluster, single-server DEV domain use server
#================================

cd('/')
cmo.createJMSSystemResource('JmsModuleRubix')
cd('/SystemResources/JmsModuleRubix')
set('Targets',jarray.array([ObjectName('com.bea:Name=rbx_dev_wls_cluster,Type=Cluster')], ObjectName))

#================================
# Build JMS Connection Factory
#================================

cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix')
cmo.createConnectionFactory('ConnFactoryGenericRubix')
cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix/ConnectionFactories/ConnFactoryGenericRubix')
cmo.setJNDIName('jms/cf/RubixGeneric')
cmo.setDefaultTargetingEnabled(true)
cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix/ConnectionFactories/ConnFactoryGenericRubix/SecurityParams/ConnFactoryGenericRubix')
cmo.setAttachJMSXUserId(false)

#================================
# Build JMS Connection Factory XA
#================================

cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix')
cmo.createConnectionFactory('ConnFactoryGenericRubixXA')
cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix/ConnectionFactories/ConnFactoryGenericRubixXA')
cmo.setJNDIName('jms/cf/RubixGenericXA')
cmo.setDefaultTargetingEnabled(true)
cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix/ConnectionFactories/ConnFactoryGenericRubixXA/SecurityParams/ConnFactoryGenericRubixXA')
cmo.setAttachJMSXUserId(false)
cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix/ConnectionFactories/ConnFactoryGenericRubixXA/TransactionParams/ConnFactoryGenericRubixXA')
cmo.setTransactionTimeout(3600)
cmo.setXAConnectionFactoryEnabled(true)

#==========================================================================
# Finalize
#==========================================================================

save()
activate()
disconnect()

#================================
# End
#================================

Create 3 queues, a request, response and a error queue.
Failure is configured to use redirect to the error queue.
A read service (hence the SR naming) mechanism I like to combine for the Oracle Service Bus

Execute the script:  java weblogic.WLST scriptname.jy import.properties


#================================================================
# Build JMS Subdeployment
#================================================================

cd('/SystemResources/JmsModuleRubix')
cmo.createSubDeployment('RBX.myDivision')
cd('/SystemResources/JmsModuleRubix/SubDeployments/RBX.myDivision')
set('Targets',jarray.array([ObjectName('com.bea:Name=rbx_dev_wls_cluster,Type=Cluster')], ObjectName))

#================================================================
# Build Queues: SR01.getMyData
#================================================================

# Error Queue
cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix')
cmo.createUniformDistributedQueue('SR01.getMyData.Error')
cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix/UniformDistributedQueues/SR01.getMyData.Error')
cmo.setJNDIName('jms/queue/SR/getMyData/Error')
cmo.setLoadBalancingPolicy('Round-Robin')
cmo.setSubDeploymentName('RBX.myDivision')

# Request queue
cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix')
cmo.createUniformDistributedQueue('SR01.getMyData.Request')
cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix/UniformDistributedQueues/SR01.getMyData.Request')
cmo.setJNDIName('jms/queue/SR/getMyData/Request')
cmo.setLoadBalancingPolicy('Round-Robin')
cmo.setSubDeploymentName('RBX.myDivision')
cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix/UniformDistributedQueues/SR01.getMyData.Request/DeliveryFailureParams/SR01.getMyData.Request')
cmo.setRedeliveryLimit(3)
cmo.setExpirationPolicy('Redirect')
cmo.setErrorDestination(getMBean('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix/UniformDistributedQueues/SR01.getMyData.Error'))

# Response Queue
cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix')
cmo.createUniformDistributedQueue('SR01.getMyData.Response')
cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix/UniformDistributedQueues/SR01.getMyData.Response')
cmo.setJNDIName('jms/queue/SR/getMyData/Response')
cmo.setLoadBalancingPolicy('Round-Robin')
cmo.setSubDeploymentName('RBX.myDivision')
cd('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix/UniformDistributedQueues/SR01.getMyData.Response/DeliveryFailureParams/SR01.getMyData.Response')
cmo.setRedeliveryLimit(3)
cmo.setExpirationPolicy('Redirect')
cmo.setErrorDestination(getMBean('/JMSSystemResources/JmsModuleRubix/JMSResource/JmsModuleRubix/UniformDistributedQueues/SR01.getMyData.Error'))
Advertisements
 
3 Comments

Posted by on 01-12-2011 in Weblogic, WLST

 

Tags: , ,

3 responses to “Creating Weblogic JMS components with WLST

  1. Edwin

    25-06-2012 at 17:12

    He,

    where are the subdeployment creation scripts.

    lazy dude , heheh
    great work

     
    • jvzoggel

      26-06-2012 at 07:04

      you can post yours here ;-) thanx :P

       

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: