我编写了一个wlst脚本来创建多个连接工厂。代码如下:
def createJMSConnFac(systemModuleName,ConnectionFactoryJNDIName,connectionFactoryName):
cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName)
cmo.createConnectionFactory(connectionFactoryName)
cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName)
cmo.setJNDIName(ConnectionFactoryJNDIName)
print "Created a ConnectionFactory !!"
cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName+'/SecurityParams/'+connectionFactoryName)
cmo.setAttachJMSXUserId(false)
cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName)
cmo.setDefaultTargetingEnabled(true)
print "Targeted the ConnectionFactory !!"
调用此方法的循环是:
y=1
while(y <= int(total_conf)):
print '----------- Connection Factory Creation ---------'
print 'Total Conf :' +total_conf
conf_name=configProps.get("conf_name"+ str(a) + "." +str(y))
conf_jndi=configProps.get("conf_jndi"+ str(a) + "." +str(y))
print 'Conf Name :' +conf_name
print 'Conf JNDI :' +conf_jndi
print 'Conf JMS Mod Name :'+jms_mod_name
print a
print y
createJMSConnFac(jms_mod_name,conf_jndi,conf_name)
y = y + 1
这里要注意的有趣事情是:它正确地创建connfac1但是一旦它第二次迭代,它就会抛出一个错误说:
WLSTException: Error cding to the MBean on line 4
在两次迭代中正确打印jms_mod_name,conf_jndi和conf_name的值。 还有什么我可能会在这里失踪?请求帮助
谢谢, Bhavin
答案 0 :(得分:1)
我能够使用以下代码创建3个(或更多)CF:
def createJMSConnFac(systemModuleName,ConnectionFactoryJNDIName,connectionFactoryName):
cmo=cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName)
cmo.createConnectionFactory(connectionFactoryName)
cmo=cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName)
cmo.setJNDIName(ConnectionFactoryJNDIName)
print "Created a ConnectionFactory !!"
cmo=cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName+'/SecurityParams/'+connectionFactoryName)
cmo.setAttachJMSXUserId(false)
cmo=cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName)
cmo.setDefaultTargetingEnabled(true)
print "Targeted the ConnectionFactory !!"
connect("weblogic","password","t3://host:port")
edit()
startEdit()
y=1
while(y <= 3):
print '----------- Connection Factory Creation ---------'
conf_name="conf_name." +str(y)
conf_jndi="conf_jndi." +str(y)
print 'Conf Name :' +conf_name
print 'Conf JNDI :' +conf_jndi
#print a
print y
createJMSConnFac('testModule',conf_jndi,conf_name)
y = y + 1
save()
activate(block="true")
disconnect()