Tuesday, March 12, 2013

Creating Forign JMS Server configuration through WLST script in weblogic server

Creating Forign JMS Server configuration through WLST script in weblogic server:

WebLogic JMS enables you to reference foreign (that is, external) JMS providers within a local WebLogic JNDI tree. Using the Foreign JMS Server node, you can quickly map a foreign JMS provider so that its connection factories and destinations appear in the WebLogic JNDI tree as a local JMS objects. A Foreign JMS Server configuration can also be used to reference remote instances of WebLogic Server in another cluster or domain in the local WebLogic JNDI tree

The below WLST script help us to create a Foreign JNDI server in a local server for a JMS resources running in a remote server(in different domain).

The JMS clients can use the local JNDI configured in the local server to send the messages to the remote JMS server.

ConfigureForeignJMSServer.py

connect('weblogic','welcome1', 't3://localhost:9001')
edit()
startEdit()

cd('/')
cmo.createJMSSystemResource('BAMForeginJMSResource')

cd('/SystemResources/BAMForeginJMSResource')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource')
cmo.createForeignServer('BAMForeignJMSServer')

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource/ForeignServers/BAMForeignJMSServer')
cmo.setDefaultTargetingEnabled(true)

cmo.setJNDIPropertiesCredential('welcome1')

cmo.setConnectionURL('t3://localhost:8000')
cmo.createJNDIProperty('java.naming.security.principal')

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource/ForeignServers/BAMForeignJMSServer/JNDIProperties/java.naming.security.principal')
cmo.setValue('weblogic')

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource/ForeignServers/BAMForeignJMSServer')

cmo.createForeignConnectionFactory('ForeignJMSConnectionFactory')

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource/ForeignServers/BAMForeignJMSServer/ForeignConnectionFactories/ForeignJMSConnectionFactory')
cmo.setLocalJNDIName('jms/BAMMonitoringConnectionfactory')
cmo.setRemoteJNDIName('jms/BAMMonitoringConnectionfactory')

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource/ForeignServers/BAMForeignJMSServer')
cmo.createForeignDestination('ForeignJMSDestination')

cd('/JMSSystemResources/BAMForeginJMSResource/JMSResource/BAMForeginJMSResource/ForeignServers/BAMForeignJMSServer/ForeignDestinations/ForeignJMSDestination')
cmo.setLocalJNDIName('jms/BAMMonitoringQueue')
cmo.setRemoteJNDIName('jms/BAMMonitoringQueue')

activate()


The same script can be modified to create a Foreign JNDI Server for other JMS providers.

Login to the server, cd to the folder where the script is available and execute the script as shown below.

%MIDDLEWARE_HOME%\wlserver_10.3\common\bin\wlst.cmd ConfigureForeignJMSServer.py



Monday, March 11, 2013

Creating JMS Adapter connection factory through WLST script in weblogic server

Creating JMS Adapter connection factory through WLST script in weblogic server:

The below WLST script will help us to create the JMS adapter connection factories. Before Executing the script change the details accordingly.

configureJMSAdapterConnection.py

TargetServerName='AdminServer'

soaHome='oracle/Middleware/Oracle_SOA1'

appPathJms=soaHome+'/soa/connectors/JmsAdapter.rar'
appNameJms='JmsAdapter'
moduleOverrideNameJms=appNameJms+'.rar'
JMSJNDIName = 'eis/wls/BAMQueueConnection'
JMSConnectionfactory='jms/BAMMonitoringConnectionfactory'
#Sever Details

moduleDescriptorName='META-INF/weblogic-ra.xml'
planPathJms=soaHome+'/soa/connectors/Plan_JMS.xml'

def createJMSConnectionFactory():

        edit()
        startEdit()
        startApplication(appNameJms)
        myPlanJms=loadApplication(appPathJms, planPathJms)
        makeDeploymentPlanVariable(myPlanJms,'ConnectionInstance_eis/Jms_JNDIName_13102979357209', JMSJNDIName , '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="oracle.tip.adapter.jms.IJmsConnectionFactory"]/connection-instance/[jndi-name="'+JMSJNDIName+'"]/jndi-name',moduleOverrideNameJms)
        makeDeploymentPlanVariable(myPlanJms, 'ConfigProperty_eis/JMS_JNDIName_ConnectionFactory_Name_13102979357210', JMSConnectionfactory,'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="oracle.tip.adapter.jms.IJmsConnectionFactory"]/connection-instance/[jndi-name="'+JMSJNDIName+'"]/connection-properties/properties/property/[name="ConnectionFactoryLocation"]/value',moduleOverrideNameJms)

        myPlanJms.save();
        save();
        cd('/AppDeployments/JmsAdapter/Targets');
        updateApplication(appNameJms, planPathJms);
        activate(block='true');
     
  
def makeDeploymentPlanVariable(wlstPlan, name, value, xpath,overrideName, origin='planbased'):
    wlstPlan.destroyVariable(name)
    wlstPlan.destroyVariableAssignment(name, overrideName, moduleDescriptorName)
    variableAssignment = wlstPlan.createVariableAssignment(name, overrideName, moduleDescriptorName)
    variableAssignment.setXpath(xpath)
    variableAssignment.setOrigin(origin)
    wlstPlan.createVariable(name, value)
    print 'moduleDescriptorName=',moduleDescriptorName


def main():
       adminURL='t3://localhost:9001'
       adminUserName='weblogic'
       adminPassword='welcome1'
       connect(adminUserName, adminPassword, adminURL)
       createJMSConnectionFactory()
       disconnect()
main()

Login to the server, cd to the folder where the script is available and execute the script as shown below.

%MIDDLEWARE_HOME%\wlserver_10.3\common\bin\wlst.cmd configureJMSAdapterConnection.py



Monday, March 4, 2013

Setting up the JMS resources through WLST script in weblogic server

Setting up the JMS resources through WLST script in weblogic server:


The below WLST script help us to set up the JMS resources.

JMSConpiguration.py

connect('weblogic','weblogic', 't3://localhost:8000')

edit()
startEdit()

print 'Creating File Store'
cd('/')
cmo.createFileStore('BAMMonitoringJMSFileStore')
cd('/FileStores/BAMMonitoringJMSFileStore')
cmo.setDirectory('BAMMonitoringJMSFileStore')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))


print 'Creating JMS Server'
cd('/')
print 'Creating JMS Server.'
cmo.createJMSServer('BAMMonitoringServer')
cd('/JMSServers/BAMMonitoringServer')
cmo.setPersistentStore(getMBean('/FileStores/BAMMonitoringJMSFileStore'))
cmo.setTemporaryTemplateResource(None)
cmo.setTemporaryTemplateName(None)
cmo.addTarget(getMBean('/Servers/AdminServer'))

print 'Creating JMS Module'
cd('/')
cmo.createJMSSystemResource('BAMJMSSystemResource')
cd('/JMSSystemResources/BAMJMSSystemResource')
cmo.addTarget(getMBean('/Servers/AdminServer'))
cmo.createSubDeployment('BAMSubdeDloyment')

print 'Creating Connection Factory'
cd('/')
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource')
cmo.createConnectionFactory('BAMMonitoringConnectionfactory')
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/ConnectionFactories/BAMMonitoringConnectionfactory')
cmo.setJNDIName('jms/BAMMonitoringConnectionfactory')
#set('SubDeploymentName','BAMSubdeDloyment')
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/ConnectionFactories/BAMMonitoringConnectionfactory/SecurityParams/BAMMonitoringConnectionfactory')
cmo.setAttachJMSXUserId(false)
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/ConnectionFactories/BAMMonitoringConnectionfactory/ClientParams/BAMMonitoringConnectionfactory')
cmo.setClientIdPolicy('Restricted')
cmo.setSubscriptionSharingPolicy('Exclusive')
cmo.setMessagesMaximum(10)
#cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/ConnectionFactories/BAMMonitoringConnectionfactory/TransactionParams/BAMMonitoringConnectionfactory')
#cmo.setXAConnectionFactoryEnabled(true)
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/ConnectionFactories/BAMMonitoringConnectionfactory')
cmo.setDefaultTargetingEnabled(true)

print 'Creating Queue'
cd('/')
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource')
cmo.createQueue('BAMMonitoringQueue')
cd('/JMSSystemResources/BAMJMSSystemResource/JMSResource/BAMJMSSystemResource/Queues/BAMMonitoringQueue')
set('JNDIName','jms/BAMMonitoringQueue')
set('SubDeploymentName','BAMSubdeDloyment')
cd('/JMSSystemResources/BAMJMSSystemResource/SubDeployments/BAMSubdeDloyment')
cmo.addTarget(getMBean('/JMSServers/BAMMonitoringServer'))

print 'JMS Resources are Successfully Created'
activate()

Executing the script:

Set the environment by executing the below script
$WL_Home/wlserver_10.3/server/bin/setWLSEnv.sh
Execute JMSConpiguration.py
Wlst.sh JMSConpiguration.py



Contact Form

Name

Email *

Message *