Search This Blog

Friday, January 25, 2013

JMS Server Configuration using WLST

Most of the message orient middleware architecture designs, while preparing the proof of concept for a new business domain they need to do multiple trails and errors. Configuring for such system resource task can be simplified with Python script. is one of the phases on other hand is setting up the thresholds and quota is next phase.
WebLogic  -  JMS Servers with File Store

Before entering into the scripting let us have brief JMS details, the basic types of JMS message communications are two:

  •  Point to Point (PTP) 
  • Publisher/Subscriber (Pub/Sub)
WLST JMS Server configuration
Usually JEE development lead or architect decides which kind of messaging could be suitable for the application. Once you got the “Sign-off” for the communication mechanism, the Middleware admin will be configuring the JMS system resources.
I like Jeff West video presentation about JMS Servers and their usage with uniform distributed Queue, Topic and newly introduced Partitioned distribution. For your reference embedding the video here.


Initially, we need a JMS persistence store configuration using WLST script, that enables you to configure as many JMS servers and persistence stores as required for an application deployment. The persistence store can be created with File Store or JDBC store options. As per your domain requirement you can specify the total number in the properties file. Suppose Architect team decided to use only File Stores then we can set 0 to JDBC total store so that the loop will be disabled for that.


What we do for JMS configuration using WLST?

The base JMS configuration is going to involve the following: a. Persistence store creation with Files: For each managed server where JMS servers configured there we need to create a File store. As best practice we create a dedicated folder where all the filestores can be stored per machine. Use the same directory structure for all machines where the filestores configured. b. Persistence store with JDBC: This we can use when your JMS message persistence requires huge message sizes. c. JMS server : we need to configure as many JMS servers as managed servers involve in JMS messaging
from java.util import Properties
from java.io import FileInputStream
from java.io import File
from java import io
from java.lang import Exception
from java.lang import Throwable
import os.path
import sys

def createFlstr(fstr_name,dir_name,target_name):
        cd('/')
        fst = create(fstr_name, "FileStore")
        cd('/FileStores/'+fstr_name)
        cmo.setDirectory(dir_name)
        fst.addTarget(getMBean("/Servers/"+target_name))

def createJDstr(jstr_name,ds_name,target_name,prefix):
        cd('/')
        jst = create(jstr_name, "JDBCStore")
        cd('/JDBCStores/'+jstr_name)
        cmo.setDataSource(getMBean('/SystemResources/'+ds_name))
        cmo.setPrefixName(prefix)
        jst.addTarget(getMBean("/Servers/"+target_name))

def createJMSsrvr(jms_srv_name,target_name,persis_store,page_dir, thrs_high, thrs_low, msg_size):
        cd('/')
        srvr = create(jms_srv_name, "JMSServer")
        cd('/Deployments/'+jms_srv_name)
        srvr.setPersistentStore(getMBean('/FileStores/'+persis_store))
#       srvr.setPersistentStore(getMBean('/JDBCStores/'+persis_store))
        srvr.setPagingDirectory(page_dir)
        srvr.addTarget(getMBean("/Servers/"+target_name))
        srvr.setBytesThresholdLow(long(thrs_low))
        srvr.setBytesThresholdHigh(long(thrs_high))
        srvr.setMaximumMessageSize(long(msg_size))

envproperty=""
if (len(sys.argv) > 1):
    envproperty=sys.argv[1]
else:
    print "Environment Property file not specified"
    sys.exit(2)
propInputStream=FileInputStream(envproperty)
configProps=Properties()
configProps.load(propInputStream)

adminUser=configProps.get("adminUser")
adminPassword=configProps.get("adminPassword")
adminURL=configProps.get("adminURL")

connect(adminUser,adminPassword,adminURL)

edit()
startEdit()

#=============# JMS SERVER and PERSISITENT STORE CONFIGURATION #=============#
total_fstore=configProps.get("total_fstore")
#total_jstore=configProps.get("total_jstore")
total_jmssrvr=configProps.get("total_jmssrvr")

j=1
while (j <= int(total_jmssrvr)):
        jms_srv_name=configProps.get("jms_srvr_name"+ str(j))
        trg=configProps.get("jms_srvr_target"+ str(j))
        persis_store=configProps.get("jms_srvr_persis_store_name"+str(j))
        page_dir=configProps.get("jms_srvr_pag_dir"+str(j))
        thrs_high=configProps.get("jms_srvr_by_threshold_high"+str(j))
        thrs_low=configProps.get("jms_srvr_by_threshold_low"+str(j))
        msg_size=configProps.get("jms_srvr_max_msg_size"+str(j))
        createFlstr(persis_store,page_dir,trg)
        createJMSsrvr(jms_srv_name,trg,persis_store,page_dir,thrs_high,thrs_low,msg_size)
        j = j+1
#==========================================================================================#
save()
activate()
To execute this script you need to workout on your properties file, indentation in the script.
$ java weblogic.WLST jms_servers.py jms_servers.properties

Generic advantage of this Script

Here most important thing is that when you wish that the persistance store could be a filestore then, it requires file path, if you are giving in the properties file assign absoulute path.
Sample properties file here
adminUser=weblogic
adminPassword=welcome1
adminURL=t3://192.168.1.106:8100
total_fstore=2
total_jmssrvr=2

jms_srvr_name1=jms_ms1
jms_srvr_target1=ms1
jms_srvr_persis_store_name1=jms_ms1_fs
jms_srvr_pag_dir1=/home/wlsdomains/demodomain/fs
jms_srvr_by_threshold_high1=10
jms_srvr_by_threshold_low1=5
jms_srvr_max_msg_size1=512

jms_srvr_name2=jms_ms2
jms_srvr_target2=ms2
jms_srvr_persis_store_name2=jms_ms2_fs
jms_srvr_pag_dir2=/home/wlsdomains/demodomain/fs
jms_srvr_by_threshold_high2=10
jms_srvr_by_threshold_low2=5
jms_srvr_max_msg_size2=512

4 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. when i execute this properties file i shows me error like this:
    [oracle@WLS-Node1 lib]$ java weblogic.WLST jmsServer.py jmsServer.properties
    Exception in thread "main" java.lang.NoClassDefFoundError: weblogic/WLST
    Caused by: java.lang.ClassNotFoundException: weblogic.WLST
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
    Could not find the main class: weblogic.WLST. Program will exit.

    ReplyDelete
    Replies
    1. @Zia, This is the WLST starting issue. You can resolve it by setting the CLASSPATH with weblogic.jar path. Or else you can use wlst.sh script which will set all required variables then it launches the WLST shell. Please follow the this http://wlstbyexamples.blogspot.in/2010/09/wlst-issues.html post.

      Delete
  3. thanks for the reply... i have set the Environment var .now iam not getting the above error ,,,instead iam getting this error in line 45

    NameError: propInputStream

    HOW TO SOLVE IT SIR?

    ReplyDelete

Please write your comment here

Popular Posts