Search This Blog

Wednesday, August 31, 2022

JMS Module with ConnectionFactory and Queue configuration using WLST

After almost three and half years again revisited to the JMS module script. This time the project needs are quite different. Where the Oracle WebLogic domains classified environments  but they are standalone server domains. That is only AdminServer will be there in the domain and that would be target for the JMS module, JMS Destinations.



Lets begin the experimenting now, the prerequisites for this are:

  1. A WebLogic Domain configured with single AdminServer
  2. AdminServer should be up and RUNNING
  3. To execute the WLST script required PATH, alias should be defined in the profile as shown below:
  4. export MW_HOME=/u01/app/oracle/fmw
    export WL_HOME=$MW_HOME/wls/wlserver
    export USER_MEM_ARGS="-Djava.security.egd=file:/dev/./urandom"
    alias wlst="$MW_HOME/oracle_common/common/bin/wlst.sh -skipWLSModuleScanning"
    

    You can use this freshly created alias wlst at any directory to invoke WLST shell.  The option -skipWLSModuleScanning is easy, faster learnt while working on docker containers and simple way to use.

  5. Execute the configure JMS Servers
  6. The WLST Script for JMS configurations and all frequently changing values are moved into the properties file.


#========================================
# WLST Script purpose: Configuring JMS Module
# Author: Pavan Devarakonda
# Update date: 3rd Aug 2017
#========================================
from java.util import Properties
from java.io import FileInputStream
from java.io import File
from java.io import FileOutputStream
from java import io
from java.lang import Exception
from java.lang import Throwable
import os.path
import sys

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)

##########################################
# Create JMS Moudle will take the 
# arguments as name, subdeployment name
# target can be on admin or managed server or cluster
##########################################
def createJMSModule(jms_module_name, adm_name, subdeployment_name):
        cd('/JMSServers')
        jmssrvlist=ls(returnMap='true')
        print jmssrvlist
        cd('/')
        module = create(jms_module_name, "JMSSystemResource")
        #cluster = getMBean("Clusters/"+cluster_target_name)
        #module.addTarget(cluster)
        #adm_name=get('AdminServerName')
        adm=getMBean("Servers/"+adm_name)
        module.addTarget(adm)
        cd('/SystemResources/'+jms_module_name)

        module.createSubDeployment(subdeployment_name)
        cd('/SystemResources/'+jms_module_name+'/SubDeployments/'+subdeployment_name)
        list=[]
        for j in jmssrvlist:
                s='com.bea:Name='+j+',Type=JMSServer'
                list.append(ObjectName(str(s)))
        set('Targets',jarray.array(list, ObjectName))


def getJMSModulePath(jms_module_name):
        jms_module_path = "/JMSSystemResources/"+jms_module_name+"/JMSResource/"+jms_module_name
        return jms_module_path

def createJMSTEMP(jms_module_name,jms_temp_name):
        jms_module_path= getJMSModulePath(jms_module_name)
        cd(jms_module_path)
        cmo.createTemplate(jms_temp_name)
        cd(jms_module_path+'/Templates/'+jms_temp_name)
        cmo.setMaximumMessageSize(20)

##########################################
# JMS Queu configuration function 
# arguments are : JMS module name, Queue jndiname
# Queue name, jndi name hu
##########################################
def createJMSQ(jms_module_name,jndi,jms_queue_name):
        jms_module_path = getJMSModulePath(jms_module_name)
        cd(jms_module_path)
        cmo.createQueue(jms_queue_name)
        cd(jms_module_path+'/Queues/'+jms_queue_name)
        cmo.setJNDIName(jndi)
        cmo.setSubDeploymentName(subdeployment_name)

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

connect(adminUser,adminPassword,adminURL)
#adm_name=get('AdminServerName')
adm_name=ls('Servers',returnMap='true')[0]
print adm_name
edit()
startEdit()

##########################################
#   JMS CONFIGURATION## 
##########################################
total_conf=configProps.get("total_conf")
tot_djmsm=configProps.get("total_default_jms_module")
#subdeployment_name=configProps.get("subdeployment_name")

a=1
while(a <= int(tot_djmsm)):
        i=int(a)
        jms_mod_name=configProps.get("jms_mod_name"+ str(i))
        #cluster=configProps.get("jms_mod_target"+ str(i))
        subdeployment_name=configProps.get("subdeployment_name"+ str(i))
        createJMSModule(jms_mod_name,adm_name,subdeployment_name)
        total_q=configProps.get("total_queue"+str(i))
        j=1
        while(j <= int(total_q)):
                queue_name=configProps.get("queue_name"+ str(i)+str(j))
                queue_jndi=configProps.get("queue_jndi"+ str(i)+str(j))
                createJMSQ(jms_mod_name,queue_jndi,queue_name)
                j = j + 1
        i=i+1
        a = a+1
save()
activate(block="true")
disconnect() 


Now see this is a sample of properties file that could help you to build the JMS Module, be read by the WLST script at the run time:
###################################################
# JMS SUBDEPLOY CONFIGURATION
###################################################
total_subdply=2
total_default_jms_module=2
total_conf=0
subdeployment_name1=DemoJMSFAServer1
subdeployment_name2=DemoJMSFAServer2

###################################################
# JMS MODULE CONFIGURATION
###################################################
jms_mod_name1=Demo-SystemModule1
jms_mod_name2=Demo-SystemModule2

###################################################
# JMS CONNECTION FACTORY CONFIGURATION
###################################################
conf_jndi1=demoCF
conf_name1=jms/demoCF

###################################################
#   JMS QUEUE CONFIGURATION
###################################################

total_queue1=2
queue_name11=Q1
queue_jndi11=Q1

queue_name12= BQ1
queue_jndi12= BQ1


total_queue2=2
queue_name21=Q2
queue_jndi21=Q2

queue_name22= BQ2
queue_jndi22= BQ2

#========== ADMIN DETAILS =========================
adminUser=weblogic
adminPassword=welcome1
adminURL=t3://192.168.33.100:8100
output
$ wlst jms_module.py jms_module.properties

let's see what happen when you apply this logic on your project? Did you notice any errors? Please write back 🔙 with your error screen shot. 

How do you know everything went well? Open the WebLogic Administration console to check the JMS Module Configuration has successfully created a new JMS resource or not.

You may be intrested to learn more WLST scripting for JMS you can also visit the Uniform Distributed Queue configuration post. Thanks for being with us in this post, Please write to us your errors and exceptions when you run this script.

9 comments:

  1. Great content. Thanks for sharing this valuable information. It will be useful for knowledge seekers.
    JMeter Training in Chennai
    JMeter Online Training
    JMeter Training Institute in Chennai
    JMeter Certification

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. 10.0.6 youtube - Videoodl.cc
    youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube channel. youtube converter youtube channel. youtube channel.

    ReplyDelete
  4. Slotyro, Casino and Gaming - Mapyro
    Find the 의왕 출장안마 best slots at Mapyro Casino. 시흥 출장샵 New & existing 춘천 출장안마 players only. Min deposit 밀양 출장마사지 €10. Max bonus 평택 출장샵 spins 40xWins.

    ReplyDelete
  5. Great article. Thanks to your blog, I am learning so much.Continually post.
    Colleges In Hyderabad For B.com


    ReplyDelete
  6. Really fascinating blog that aids in my acquisition of in-depth technological information. I appreciate you giving such a lovely blog.
    Nice conversation. B.Com Computers Colleges In Hyderabad

    ReplyDelete
  7. A very good article. This article offers high-quality information. Definitely, I'll look at it. These are some very beneficial pointers. Thank you very much. Keep up the fantastic work.Best Colleges For BBA In Hyderabad


    ReplyDelete
  8. A very good article. This article offers high-quality information. Definitely, I'll look at it. These are some very beneficial pointers. Thank you very much. Keep up the fantastic work.
    Best Colleges in Hyderabad For BBA

    ReplyDelete

Please write your comment here

Popular Posts