Creating JMS server, JMS module, JMS Connection Factory and JMS Queue through WLST

In this post we will see how to Creating JMS server, JMS module, JMS Connection Factory and JMS Queue using wlst scripts.

Create a directory in your system and create a properties file with below information and name it as “JMSconfig.properties“.

# 1 – ENTER Server Connection details
server.url = t3://localhost:7001
username = weblogic
password = welcome1

# 2 – ENTER JMSServer details
jms.server.name = TEST_JMSServer
store.name = TEST_JDBCStore
tragated.jms.server.name = AdminServer

# 3 – ENTER  SystemModule Details
system.module.name = TEST_JMSModule
tragated.system.module.name = AdminServer

# 4 – ENTER  ConnectionFactory Details
connection.factory.name = TEST_ConnectionFactory
connection.factory.jndi.name = jms/TEST_CF

# 5 – ENTER  Unit Of Order Details
unit.of.order.value = 1

# 6 – ENTER  SubDeployment & Queue Details
queue.sub.deployment.name = Sub_TEST_Queue
queue.name = TEST_Queue
queue.jndi.name = jms/TEST_Q

Now in the same directory create a new file for JMS script with below script and name it as “JMSConfig.py

from java.io import FileInputStream
import java.lang
import os
import string

propInputStream = FileInputStream(“domain.properties”)
configProps = Properties()
configProps.load(propInputStream)

# 1 – Connecting details
serverUrl = configProps.get(“server.url”)
Username = configProps.get(“username”)
Password = configProps.get(“password”)

# 2 – JMSServer details
jmsServerName = configProps.get(“jms.server.name”)
storeName = configProps.get(“store.name”)
tragatedJMSServerName = configProps.get(“tragated.jms.server.name”)

# 3 – SystemModule Details
systemModuleName = configProps.get(“system.module.name”)
tragatedSystemModuleName = configProps.get(“tragated.system.module.name”)

# 4 – ConnectionFactory Details
connectionFactoryName = configProps.get(“connection.factory.name”)
ConnectionFactoryJNDIName = configProps.get(“connection.factory.jndi.name”)

# 5 – Unit Of Order Details
unitOfOrderValue = configProps.get(“unit.of.order.value”)

# 6 – SubDeployment & Queue Details
queueSubDeploymentName = configProps.get(“queue.sub.deployment.name”)
queueName = configProps.get(“queue.name”)
queueJNDIName = configProps.get(“queue.jndi.name”)

redirect(‘wlst.log’,’false’)

# 1 – Connecting to the Destination
connect(Username,Password,serverUrl)

edit()

# 2 – JMSServer details
print “================== JMSSever ===================”
startEdit()
cmo.createJMSServer(jmsServerName)
print “Created a JMSServer !!”
cd(‘/Deployments/’+jmsServerName)
cmo.setPersistentStore(getMBean(‘/JDBCStores/’+storeName))
print “PersistentStore has been set for the JMSServer !!”
set(‘Targets’,jarray.array([ObjectName(‘com.bea:Name=’+tragatedJMSServerName+’,Type=Server’)], ObjectName))
print “Targeted the JMSServer !!”
activate()
print “”

# 3 – SystemModule Details
print “================== SystemModule ===================”
startEdit()
cd(‘/’)
cmo.createJMSSystemResource(systemModuleName)
print “Created a SystemModule !!”
cd(‘/SystemResources/’+systemModuleName)
set(‘Targets’,jarray.array([ObjectName(‘com.bea:Name=’+tragatedSystemModuleName+’,Type=Server’)], ObjectName))
print “Targeted the SystemModule !!”
activate()
print “”

# 4 – ConnectionFactory Details
print “================== ConnectionFactory ===================”
startEdit()
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 !!”
activate()
print “”

# 5 – Unit Of Order Details
print “================== Unit Of Order ===================”
startEdit()
cd(‘/JMSSystemResources/’+systemModuleName+’/JMSResource/’+systemModuleName+’/ConnectionFactories/’+connectionFactoryName+’/DefaultDeliveryParams/’+connectionFactoryName)
cmo.setDefaultUnitOfOrder(unitOfOrderValue)
print “Changed Unit Of Order !!”
activate()
print “”

# 6 – SubDeployment & Queue Details
print “================== SubDeployment & Queue ===================”
startEdit()
cd(‘/SystemResources/’+systemModuleName)
cmo.createSubDeployment(queueSubDeploymentName)
print “Created a SubDeployment for Queue !!”
cd(‘/JMSSystemResources/’+systemModuleName+’/JMSResource/’+systemModuleName)
cmo.createQueue(queueName)
print “Created a Queue !!”
cd(‘/JMSSystemResources/’+systemModuleName+’/JMSResource/’+systemModuleName+’/Queues/’+queueName)
cmo.setJNDIName(queueJNDIName)
cmo.setSubDeploymentName(queueSubDeploymentName)
cd(‘/SystemResources/’+systemModuleName+’/SubDeployments/’+queueSubDeploymentName)
set(‘Targets’,jarray.array([ObjectName(‘com.bea:Name=’+jmsServerName+’,Type=JMSServer’)], ObjectName))
print “Targeted the Queue to the created subdeployment !!”
activate()
print “”

cmd = “rm -f wlst.log”
os.system(cmd)

To use this script, we need to edit the properties file at the top of the program.

Now place both the properties and python file  in the server location(cd /your/fmwhome/wlserver/server/bin/)

Set the domain environment by running the below command.

cd /your/fmwhome/wlserver/server/bin/> setDomainEnv.cmd

Now run the python script with below command.

/your/fmwhome/wlserver/server/bin/>  java weblogic.WLST JMSConfig.py

High availability setup for Oracle MFT 12.2.1.0.0

In this post we will post see how to configure MFT for high availability.

If you wont setup the high availability properties in mft console in a cluster environment then you will face the issues with file polling.

For high availability we have to set the below properties.

Control Directory–> is the directory path which MFT File/FTP adapters require to
handle HA use cases. This field is required if the MFT is running in HA
environment. You must set it to a shared location if multiple Oracle WebLogic
Server instances run in a cluster, for example $DOMAIN_HOME/mft/control_di.

Inbound Datasource –>is the inbound data source of MFT where the schemas
corresponding to high availability are precreated. This field is required if the
Control Directory is not provided. The default, established outside of Oracle
Managed File Transfer, is jdbc/MFTDataSource.

Outbound Datasource –> is the outbound data source of MFT where the schemas
corresponding to high availability are precreated. This field is required if the
Control Directory is not provided. The default, established outside of Oracle
Managed File Transfer, is jdbc/MFTDataSource.

Create a control directory in your domain home and name it like “control_di”.

Login to mftconsole and go to administration –> Server properties

In High availability properties provide the newly created control directory location and data source jndi name in both inbound and outbound datasource.

mfthighavilabilityproperties.JPG

Configure Custom Oracle MFT Notifications in SOA Suite 12.2.1.0.0

Usually in our projects we get the requirement for sending the notifications for all success and failures . But in my MFT we don’t have direct option or event available to achieve this requirement.

When the transfer is successful user needs to be notified via email so that they can take further action.
User can set filter criteria for file name and file size for which notification needs to be sent.

Follow the below steps for running this sample :

1. Import the transfer(mytransfer_export.zip). This will automatically add the callout definition to the repository. You can also download the callout definition XML(postTransferNotification.xml), if you manually want to create the callout definition.
2. Download the callout jar (postTransferNotification.jar) and source code (PostTransferNotification.java)
3. Download the email template (template.eml) (don’t forget to change the email address in the template) file and place it under template location specified in the notification callout associated with the target.
4. Go to MFT Console -> Administration tab -> Server Properties -> General Configuration . Check for the custom callout directory setting and place the jar,xml and eml template in that folder.

Installing Callout with WLST command:-

a. Run WLST using: $ $MW_HOME/mft/common/bin/wlst.sh
b. Connect to MFT server using the below command :
connect(“admin user”, “password”, “t3://localhost:mftport”)
c. listCallouts()
d. createCallouts(‘ $DOMAIN_HOME/mft/callouts/postTransferNotification.xml’)
e. listCallouts()

Login to MFT console :-
5. Deploy the transfer from the MFT console

Go To Design Page and Open the Transfers – >  in target -> Post Process Actions:
Click “add post-processing actions” and you will see a drop down list with newly created callout, select it and click on add to list .

Provide the location of the “Email Template File location” as step 4 .

6. Please make sure that the ums email drivers for the mft server is configured properly.
7. Send the sample file to embedded ftp server in the /mymart.

To Download the files ClickHere

Creating Data source and DB adapter outbound connection pool using WLST

In this post we will see how to create a data source , DB adapter outbound connection pool and redeployment using wlst scripts.

Lets look at the script which creates both DS and DB adapter connection pool and redeployment.

import time

# admin server url
url = ‘t3://localhost:7001’
# username to connect to the admin server
username = ‘weblogic’
# password to connect to the admin server
password = ‘welcome1’
# the name for the EIS
eisName = ‘eis/db/myDS’
# the admin or managed server to target where the DbAdapter is deployed
serverName = ‘AdminServer’
#nmServerName = ‘soa_server1’
# the name for the data source
dsName = ‘myDS’
# the JNDI name for the data source
jndiName = ‘jbdc/myDS’
# the database url for the data source
dbUrl = ‘jdbc:oracle:thin:@localhost:1522:SOAORA’
# the database user
dbUser = ‘soa12c_soainfra’
# the database password
dbPassword = ‘welcome_1’
# the database driver to use
dbDriver = ‘oracle.jdbc.xa.client.OracleXADataSource’
# the host where node manager is running
#nmHost = ‘localhost’
# the port to connect to node manager (5556 is default for plain mode)
#nmPort = ‘5556’
# the user to connect to node manager
#nmUser = ‘weblogic’
# the password to connection to node manager
#nmPassword = ‘welcome1’
# the name of the weblogic domain
domain = ‘soa12c_domain’

# don’t change the below ones
uniqueString = ”
appName = ‘DbAdapter’
moduleOverrideName = appName+’.rar’
moduleDescriptorName = ‘META-INF/weblogic-ra.xml’

#
# method definitions
#

def makeDeploymentPlanVariable(wlstPlan, name, value, xpath, origin=’planbased’):

try:
variableAssignment = wlstPlan.createVariableAssignment(name, moduleOverrideName, moduleDescriptorName)
variableAssignment.setXpath(xpath)
variableAssignment.setOrigin(origin)
wlstPlan.createVariable(name, value)

except:
print(‘–> was not able to create deployment plan variables successfully’)

def main():

uniqueString = str(int(time.time()))

#
# Create a JDBC Data Source.
#

try:
print(‘–> about to connect to weblogic’)
connect(username, password, url)
print(‘–> about to create a data source ‘ + dsName)
edit()
startEdit()
cmo.createJDBCSystemResource(dsName)
cd(‘/JDBCSystemResources/’ + dsName + ‘/JDBCResource/’ + dsName)
cmo.setName(dsName)
cd(‘/JDBCSystemResources/’ + dsName + ‘/JDBCResource/’ + dsName + ‘/JDBCDataSourceParams/’ + dsName)
set(‘JNDINames’,jarray.array([String(jndiName)], String))
cd(‘/JDBCSystemResources/’ + dsName + ‘/JDBCResource/’ + dsName + ‘/JDBCDriverParams/’ + dsName)
cmo.setUrl(dbUrl)
cmo.setDriverName(dbDriver)
cmo.setPassword(dbPassword)
cd(‘/JDBCSystemResources/’ + dsName + ‘/JDBCResource/’ + dsName + ‘/JDBCConnectionPoolParams/’ + dsName)
cmo.setTestTableName(‘DUAL’)
cd(‘/JDBCSystemResources/’ + dsName + ‘/JDBCResource/’ + dsName + ‘/JDBCDriverParams/’ + dsName + ‘/Properties/’ + dsName)
cmo.createProperty(‘user’)
cd(‘/JDBCSystemResources/’ + dsName + ‘/JDBCResource/’ + dsName + ‘/JDBCDriverParams/’ + dsName + ‘/Properties/’ + dsName + ‘/Properties/user’)
cmo.setValue(dbUser)
cd(‘/JDBCSystemResources/’ + dsName + ‘/JDBCResource/’ + dsName + ‘/JDBCDataSourceParams/’ + dsName)
cmo.setGlobalTransactionsProtocol(‘TwoPhaseCommit’)
cd(‘/JDBCSystemResources/’ + dsName)
set(‘Targets’,jarray.array([ObjectName(‘com.bea:Name=’ + serverName + ‘,Type=Server’)], ObjectName))
save()
print(‘–> activating changes’)
activate()
print(‘–> done’)

#
# update the deployment plan
#
print(‘–> about to update the deployment plan for the DbAdapter’)
startEdit()
planPath = get(‘/AppDeployments/DbAdapter/PlanPath’)
appPath = get(‘/AppDeployments/DbAdapter/SourcePath’)
print(‘–> Using plan ‘ + planPath)
plan = loadApplication(appPath, planPath)
print(‘–> adding variables to plan’)
makeDeploymentPlanVariable(plan, ‘ConnectionInstance_eis/DB/’ + dsName + ‘_JNDIName_’ + uniqueString, eisName, ‘/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface=”javax.resource.cci.ConnectionFactory”]/connection-instance/[jndi-name=”‘ + eisName + ‘”]/jndi-name’)
makeDeploymentPlanVariable(plan, ‘ConfigProperty_xADataSourceName_Value_’ + uniqueString, eisName, ‘/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface=”javax.resource.cci.ConnectionFactory”]/connection-instance/[jndi-name=”‘ + eisName + ‘”]/connection-properties/properties/property/[name=”xADataSourceName”]/value’)
print(‘–> saving plan’)
plan.save();
save();
print(‘–> activating changes’)
activate(block=’true’);
cd(‘/AppDeployments/DbAdapter/Targets’);
print(‘–> redeploying the DbAdapter’)
redeploy(appName, planPath, targets=cmo.getTargets());
print(‘–> done’)

except:
print(‘–> something went wrong, bailing out’)
stopEdit(‘y’)
raise SystemExit

#
# disconnect from the admin server
#

print(‘–> disconnecting from admin server now’)
disconnect()

#
# this is the main entry point
#

main()

To use this script, we need to edit the parameters at the top of the program.

save it somewhere in the server location(cd /your/fmwhome/wlserver/server/bin/) with name like “createMyDS.py”

Set the domain environment by running the below command.

cd /your/fmwhome/wlserver/server/bin/> setDomainEnv.cmd

Now run the python script with below command.

/your/fmwhome/wlserver/server/bin/>  java weblogic.WLST createMyDS.py

Now if you open your weblogic console you will find both DS and DB adapter configured with above values.

wlstdswlstdb1

MFTDomain:Name=oracle.as.mft.runtime,Type=MFT,Application=mft-app

Issue –> when launching the wlst commands you will get the below error.

Error –> MFTDomain:Name=oracle.as.mft.runtime,Type=MFT,Application=mft-app

Cause –> The issue occurs when connecting to AdminServer, but MFT is deployed in another managed server

Solution –>

Solution is to this is connect to the mft_server instead, with this connection the MFT specific commands work as expected.

For example,  lets assume the port for AdminServer is 7001 and the port for MFT server is 7003. Connection to the MFT server is:

wls:/offline>connect(“weblogic”,”welcome1″,”t3://localhost:7003″)