This script creates JMS servers, JMS module, JMS subdeployment, one connection factory and one UDQ.
Before you run this script, you need to set environment by running following command.
. $DOMAIN_HOME/bin/setDomainEnv.sh
>>>> java weblogic.WLST jms_queue.py
Contents of jms.properties
Before you run this script, you need to set environment by running following command.
. $DOMAIN_HOME/bin/setDomainEnv.sh
>>>> java weblogic.WLST jms_queue.py
import sys
from java.util import *
from javax.management import *
from java.io import FileInputStream
print "@@@ creating JMS resources ..."
propInputStream1 = FileInputStream("jms.properties")
domainProps = util.Properties()
domainProps.load(propInputStream1)
adminURL='t3://'+domainProps.get('adminServer')+':'+domainProps.get('adminPort')
adminUserName='weblogic'
adminPassword=domainProps.get("adminPassword")
clusterName=domainProps.get('clusterName')
try:
connect(adminUserName, adminPassword, adminURL)
edit()
startEdit()
#build JMS Server1 - target to managed server
cd('Clusters/'+clusterName)
managedServers=cmo.getServers()
i = 1
for managedServer in managedServers:
managedServerName=managedServer.getName()
cd('/')
cmo.createJMSServer('JmsServer'+str(i))
cd('/Deployments/JmsServer'+str(i))
cmo.setPersistentStore(getMBean('/JDBCStores/JDBCStore_'+str(i)))
msObjectName='com.bea:Name='+managedServerName+',Type=Server'
set('Targets', jarray.array([ObjectName(msObjectName)], ObjectName))
print "@@@ created JMS Server"
i = i + 1
# Build JMS Module - target preferrable cluster
cd('/')
cmo.createJMSSystemResource('JmsModule1')
cd('/JMSSystemResources/JmsModule1')
set('Targets',jarray.array([ObjectName('com.bea:Name='+clusterName+',Type=Cluster')], ObjectName))
print "@@@ creating JMS module ..."
# Build JMS Connection Factory XA - target to cluster
cd('/JMSSystemResources/JmsModule1/JMSResource/JmsModule1')
cmo.createConnectionFactory('ConnFactoryGenericXYZXA')
cd('/JMSSystemResources/JmsModule1/JMSResource/JmsModule1/ConnectionFactories/ConnFactoryGenericXYZXA')
cmo.setJNDIName('jms/cf/XYZGenericXA')
cd('/JMSSystemResources/JmsModule1/JMSResource/JmsModule1/ConnectionFactories/ConnFactoryGenericXYZXA/TransactionParams/ConnFactoryGenericXYZXA')
#cmo.setAttachJMSXUserId(false)
cmo.setXAConnectionFactoryEnabled(true)
cd('/JMSSystemResources/JmsModule1/JMSResource/JmsModule1/ConnectionFactories/ConnFactoryGenericXYZXA')
cmo.setDefaultTargetingEnabled(true)
print "@@@ creating JMS connection factory ..."
# Build JMS Subdeployment - target to all JMS servers
cd('/JMSSystemResources/JmsModule1')
cmo.createSubDeployment('JMSSubDeploy')
cd('/JMSSystemResources/JmsModule1/SubDeployments/JMSSubDeploy')
print "@@@ creating JMS subdeployment ..."
######
list=[]
cd('/')
cd('Clusters/'+clusterName)
managedServers=cmo.getServers()
i = 1
for managedServer in managedServers:
managedServerName=managedServer.getName()
s='com.bea:Name=JmsServer'+str(i)+',Type=JMSServer'
list.append(ObjectName(str(s)))
i = i + 1
cd('/JMSSystemResources/JmsModule1/SubDeployments/JMSSubDeploy')
set('Targets',jarray.array(list, ObjectName))
print "@@@ created JMS subdeployment ..."
#Email queue - XYZ_QUEUE
cd('/JMSSystemResources/JmsModule1/JMSResource/JmsModule1')
cmo.createUniformDistributedQueue('XYZ_QUEUE')
cd('/JMSSystemResources/JmsModule1/JMSResource/JmsModule1/UniformDistributedQueues/XYZ_QUEUE')
cmo.setJNDIName('jms/xyzQueue')
cmo.setLoadBalancingPolicy('Round-Robin')
cmo.setSubDeploymentName('JMSSubDeploy')
print "@@@ completed creating JMS resources ..."
save()
activate(200000, block='true')
except Exception, e:
dumpStack()
print "@@@ exception occured"
print e
cancelEdit('y')
Contents of jms.properties
#jms.properties
adminServer=abc.xyz.com
adminPort=7101
adminPassword=xyz
clusterName=xyz_dev_cluster
dataSourceName=JMSDataSource
No comments:
Post a Comment