Saturday, 3 December 2016

Python Script - JMS Queue Creation

JMS Queue Creation


I want to create JMS Queue Creation using Python Script.

My Server Details are,

Cluster Environment: 1 Admin Server and 2 Managed Server (wls_osb1 and wls_osb2) 
Domain Name: soa_domain
Cluster Name: osb_cluster


Save below weblogic.properties file as weblogic.properties

#################################################################################
#  admin server url
   admin.url=t3://localhost:7001
#################################################################################

# Domain Name:             
domainName=soa_domain
osbServer1=wls_osb1
osbServer2=wls_osb2

#Manage Server Name:
targetServer.1=wls_osb1
targetServer.2=wls_osb2

#Cluster Name:
osb_ClusterName=osb_cluster
migrateServerType=MigratableTarget
clusterServerType=Cluster
normalServerType=Server

#################################################################################
JMS Q without Error Destination 
If you have only JMS Q or Error Q then you have to mention it here
#################################################################################

# Total how many DQ needs to be create
total.DQ=78

jms.queuename.1=AppOFMOIntmentAckAT1Error
jms.queueJNDIname.1=jms/AppOFMOIntmentAckAT1Error

jms.queuename.2=AppOFMOIntmentAckLD1Error
jms.queueJNDIname.2=jms/AppOFMOIntmentAckLD1Error

jms.queuename.3=AppOFMOIntmentAckMK1Error
jms.queueJNDIname.3=jms/AppOFMOIntmentAckMK1Error

jms.queuename.4=AppOFMOIntmentAckMP1Error
jms.queueJNDIname.4=jms/AppOFMOIntmentAckMP1Error

jms.queuename.5=AppOFMOIntmentAckUS1Error
jms.queueJNDIname.5=jms/AppOFMOIntmentAckUS1Error

jms.queuename.6=AppOFMOIntmentLD1
jms.queueJNDIname.6=jms/AppOFMOIntmentLD1

jms.queuename.7=AppOFMOIntmentMK1
jms.queueJNDIname.7=jms/AppOFMOIntmentMK1

jms.queuename.8=AppOFMOIntmentMP1
jms.queueJNDIname.8=jms/AppOFMOIntmentMP1

jms.queuename.9=AppOFMOIntmentUS1
jms.queueJNDIname.9=jms/AppOFMOIntmentUS1

jms.queuename.10=ASNAT1
jms.queueJNDIname.10=jms/ASNAT1

jms.queuename.11=ASNLD1
jms.queueJNDIname.11=jms/ASNLD1

jms.queuename.12=ASNMK1
jms.queueJNDIname.12=jms/ASNMK1

jms.queuename.13=ASNMP1
jms.queueJNDIname.13=jms/ASNMP1

jms.queuename.14=ASNUS1
jms.queueJNDIname.14=jms/ASNUS1

jms.queuename.15=ASNVerificationAT1Error
jms.queueJNDIname.15=jms/ASNVerificationAT1Error

jms.queuename.16=ASNVerificationLD1Error
jms.queueJNDIname.16=jms/ASNVerificationLD1Error

jms.queuename.17=ASNVerificationMK1Error
jms.queueJNDIname.17=jms/ASNVerificationMK1Error

jms.queuename.18=ASNVerificationMP1Error
jms.queueJNDIname.18=jms/ASNVerificationMP1Error

jms.queuename.19=ASNVerificationUS1Error
jms.queueJNDIname.19=jms/ASNVerificationUS1Error

jms.queuename.20=AT1ItemsUpdateError
jms.queueJNDIname.20=jms/AT1ItemsUpdateError

jms.queuename.21=BusinessPartnerAT1
jms.queueJNDIname.21=jms/BusinessPartnerAT1

jms.queuename.22=BusinessPartnerLD1
jms.queueJNDIname.22=jms/BusinessPartnerLD1

jms.queuename.23=BusinessPartnerMK1
jms.queueJNDIname.23=jms/BusinessPartnerMK1

jms.queuename.24=BusinessPartnerMP1
jms.queueJNDIname.24=jms/BusinessPartnerMP1

jms.queuename.25=BusinessPartnerUS1
jms.queueJNDIname.25=jms/BusinessPartnerUS1

jms.queuename.26=CompanyAT1
jms.queueJNDIname.26=jms/CompanyAT1

jms.queuename.27=CompanyLD1
jms.queueJNDIname.27=jms/CompanyLD1

jms.queuename.28=CompanyMK1
jms.queueJNDIname.28=jms/CompanyMK1

jms.queuename.29=CompanyMP1
jms.queueJNDIname.29=jms/CompanyMP1

jms.queuename.30=CompanyUS1
jms.queueJNDIname.30=jms/CompanyUS1

jms.queuename.31=DistributionOrderLD1
jms.queueJNDIname.31=jms/DistributionOrderLD1

jms.queuename.32=DistributionOrderMK1
jms.queueJNDIname.32=jms/DistributionOrderMK1

jms.queuename.33=DistributionOrderMP1
jms.queueJNDIname.33=jms/DistributionOrderMP1

jms.queuename.34=DistributionOrderUS1
jms.queueJNDIname.34=jms/DistributionOrderUS1

jms.queuename.35=DistroAT1
jms.queueJNDIname.35=jms/DistroAT1

jms.queuename.36=DistroLD1
jms.queueJNDIname.36=jms/DistroLD1

jms.queuename.37=DistroMK1
jms.queueJNDIname.37=jms/DistroMK1

jms.queuename.38=DistroMP1
jms.queueJNDIname.38=jms/DistroMP1

jms.queuename.39=DistroUS1
jms.queueJNDIname.39=jms/DistroUS1

jms.queuename.40=FacilityAT1
jms.queueJNDIname.40=jms/FacilityAT1

jms.queuename.41=FacilityLD1
jms.queueJNDIname.41=jms/FacilityLD1

jms.queuename.42=FacilityMK1
jms.queueJNDIname.42=jms/FacilityMK1

jms.queuename.43=FacilityMP1
jms.queueJNDIname.43=jms/FacilityMP1

jms.queuename.44=FacilityUS1
jms.queueJNDIname.44=jms/FacilityUS1

jms.queuename.45=ItemsAT1
jms.queueJNDIname.45=jms/ItemsAT1

jms.queuename.46=ItemsLD1
jms.queueJNDIname.46=jms/ItemsLD1

jms.queuename.47=ItemsMK1
jms.queueJNDIname.47=jms/ItemsMK1

jms.queuename.48=ItemsMP1
jms.queueJNDIname.48=jms/ItemsMP1

jms.queuename.49=ItemsUS1
jms.queueJNDIname.49=jms/ItemsUS1

jms.queuename.50=LD1ItemsUpdateError
jms.queueJNDIname.50=jms/LD1ItemsUpdateError

jms.queuename.51=MK1ItemsUpdateError
jms.queueJNDIname.51=jms/MK1ItemsUpdateError

jms.queuename.52=MP1ItemsUpdateError
jms.queueJNDIname.52=jms/MP1ItemsUpdateError

jms.queuename.53=RelationshipAT1
jms.queueJNDIname.53=jms/RelationshipAT1

jms.queuename.54=RelationshipLD1
jms.queueJNDIname.54=jms/RelationshipLD1

jms.queuename.55=RelationshipMK1
jms.queueJNDIname.55=jms/RelationshipMK1

jms.queuename.56=RelationshipMP1
jms.queueJNDIname.56=jms/RelationshipMP1

jms.queuename.57=RelationshipUS1
jms.queueJNDIname.57=jms/RelationshipUS1

jms.queuename.58=StoresAT1
jms.queueJNDIname.58=jms/StoresAT1

jms.queuename.59=StoresLD1
jms.queueJNDIname.59=jms/StoresLD1

jms.queuename.60=SampleQueue
jms.queueJNDIname.60=jms/SampleQueue

jms.queuename.61=StoresMK1
jms.queueJNDIname.61=jms/StoresMK1

jms.queuename.62=StoresMP1
jms.queueJNDIname.62=jms/StoresMP1

jms.queuename.63=StoresUS1
jms.queueJNDIname.63=jms/StoresUS1

jms.queuename.64=US1ItemsUpdateError
jms.queueJNDIname.64=jms/US1ItemsUpdateError

jms.queuename.65=ItemsIntermediateError
jms.queueJNDIname.65=jms/ItemsIntermediateError

jms.queuename.66=ItemsRMSError
jms.queueJNDIname.66=jms/ItemsRMSError

jms.queuename.67=PIXAT1
jms.queueJNDIname.67=jms/PIXAT1

jms.queuename.68=PIXLD1
jms.queueJNDIname.68=jms/PIXLD1

jms.queuename.69=PIXUS1
jms.queueJNDIname.69=jms/PIXUS1

jms.queuename.70=PIXMP1
jms.queueJNDIname.70=jms/PIXMP1

jms.queuename.71=PIXMK1
jms.queueJNDIname.71=jms/PIXMK1

jms.queuename.72=Items
jms.queueJNDIname.72=Items

jms.queuename.73=ItemsRMS1
jms.queueJNDIname.73=ItemsRMS1

jms.queuename.74=ShipmentConfirmationMP1
jms.queueJNDIname.74=jms/ShipmentConfirmationMP1

jms.queuename.75=ShipmentConfirmationMK1
jms.queueJNDIname.75=jms/ShipmentConfirmationMK1

jms.queuename.76=ShipmentConfirmationLD1
jms.queueJNDIname.76=jms/ShipmentConfirmationLD1

jms.queuename.77=ShipmentConfirmationAT1
jms.queueJNDIname.77=jms/ShipmentConfirmationAT1

jms.queuename.78=ShipmentConfirmationUS1
jms.queueJNDIname.78=jms/ShipmentConfirmationUS1

#################################################################################
JMS Q with Error Destination 
# If you have JMS Q with Error Destination then you have to mention it here
#################################################################################

#Total how many DQ with Error Destination needs to be create
total.DQ_with_ErrDst=17

jms.Dqueuename.1=AppOFMOIntmentAckAT1
jms.DqueueJNDIname.1=jms/AppOFMOIntmentAckAT1
jms.MAPerrqueueJNDIname.1=AppOFMOIntmentAckAT1Error

jms.Dqueuename.2=AppOFMOIntmentAckLD1
jms.DqueueJNDIname.2=jms/AppOFMOIntmentAckLD1
jms.MAPerrqueueJNDIname.2=AppOFMOIntmentAckLD1Error

jms.Dqueuename.3=AppOFMOIntmentAckMK1
jms.DqueueJNDIname.3=jms/AppOFMOIntmentAckMK11
jms.MAPerrqueueJNDIname.3=AppOFMOIntmentAckMK1Error

jms.Dqueuename.4=AppOFMOIntmentAckMP1
jms.DqueueJNDIname.4=jms/AppOFMOIntmentAckMP1
jms.MAPerrqueueJNDIname.4=AppOFMOIntmentAckMP1Error

jms.Dqueuename.5=AppOFMOIntmentAckUS1
jms.DqueueJNDIname.5=jms/AppOFMOIntmentAckUS1
jms.MAPerrqueueJNDIname.5=AppOFMOIntmentAckUS1Error

jms.Dqueuename.6=ASNVerificationAT1
jms.DqueueJNDIname.6=jms/ASNVerificationAT1
jms.MAPerrqueueJNDIname.6=ASNVerificationAT1Error

jms.Dqueuename.7=ASNVerificationLD1
jms.DqueueJNDIname.7=jms/ASNVerificationLD1
jms.MAPerrqueueJNDIname.7=ASNVerificationLD1Error

jms.Dqueuename.8=ASNVerificationMK1
jms.DqueueJNDIname.8=jms/ASNVerificationMK1
jms.MAPerrqueueJNDIname.8=ASNVerificationMK1Error

jms.Dqueuename.9=ASNVerificationMP1
jms.DqueueJNDIname.9=jms/ASNVerificationMP1
jms.MAPerrqueueJNDIname.9=ASNVerificationMP1Error

jms.Dqueuename.10=ASNVerificationUS1
jms.DqueueJNDIname.10=jms/ASNVerificationUS1
jms.MAPerrqueueJNDIname.10=ASNVerificationUS1Error

jms.Dqueuename.11=AT1ItemsUpdate
jms.DqueueJNDIname.11=jms/AT1ItemsUpdate
jms.MAPerrqueueJNDIname.11=AT1ItemsUpdateError

jms.Dqueuename.12=LD1ItemsUpdate
jms.DqueueJNDIname.12=jms/LD1ItemsUpdate
jms.MAPerrqueueJNDIname.12=LD1ItemsUpdateError

jms.Dqueuename.13=MK1ItemsUpdate
jms.DqueueJNDIname.13=jms/MK1ItemsUpdate
jms.MAPerrqueueJNDIname.13=MK1ItemsUpdateError

jms.Dqueuename.14=MP1ItemsUpdate
jms.DqueueJNDIname.14=jms/MP1ItemsUpdate
jms.MAPerrqueueJNDIname.14=MP1ItemsUpdateError

jms.Dqueuename.15=US1ItemsUpdate
jms.DqueueJNDIname.15=jms/US1ItemsUpdate
jms.MAPerrqueueJNDIname.15=US1ItemsUpdateError

jms.Dqueuename.16=ItemsIntermediate
jms.DqueueJNDIname.16=jms/ItemsIntermediate
jms.MAPerrqueueJNDIname.16=ItemsIntermediateError

jms.Dqueuename.17=ItemsRMS
jms.DqueueJNDIname.17=jms/ItemsRMS
jms.MAPerrqueueJNDIname.17=ItemsRMSError

#################################################################################

Now, below python script you have to save as create_JMS_Q.py

#################################################################################

#!/usr/bin/python
from java.io import FileInputStream
import time

propInputStream= FileInputStream('weblogic.properties')
configProps = Properties()
configProps.load(propInputStream)

adminURL= configProps.get('admin.url')
# Enter username and password
adminUserName= ''
adminPassword= ''

Target_Cluster=configProps.get('osb_ClusterName')
Server_type_Cluster=configProps.get('clusterServerType')

ModuleName= configProps.get('jmsModuleName')

total_jms_queue_to_create = configProps.get('total.DQ')


jmsSubdeployment = configProps.get('SubdeploymentName')
JMSServer1 = configProps.get('jmsServer.1')
JMSServer2 = configProps.get('jmsServer.2')
JMSServer3 = configProps.get('jmsServer.3')

connect(adminUserName,adminPassword,adminURL)

edit()
startEdit()
try:

#################################################################################
# Creating Error Q and Normal Q without Error Destination
#################################################################################

        i=1
        while (i <= int(total_jms_queue_to_create)):

            try:
                cd('/')
                jmsQueue = configProps.get('jms.queuename.'+ str(i))
                jmsQueueJndi = configProps.get('jms.queueJNDIname.'+ str(i))
                cd('/JMSSystemResources/'+ ModuleName + '/JMSResource/'+ ModuleName)
                cmo.createUniformDistributedQueue(jmsQueue)
                cd('/JMSSystemResources/'+ ModuleName + '/JMSResource/'+ ModuleName+'/UniformDistributedQueues/' + jmsQueue)
                set('JNDIName',jmsQueueJndi)
                set('SubDeploymentName',jmsSubdeployment)
                cd('/JMSSystemResources/'+ ModuleName +'/SubDeployments/'+jmsSubdeployment)
                set('Targets',jarray.array([ObjectName('com.bea:Name='+ JMSServer1 +',Type=JMSServer'), ObjectName('com.bea:Name='+ JMSServer2 +',Type=JMSServer')], ObjectName))
                print 'Queue: "',jmsQueue,'" has been created Successfully'
            except:

              i = i + 1
  
#################################################################################

except:
        print('--> something went wrong, bailing out', sys.exc_info()[0])
        stopEdit('y')
        raise SystemExit

save()

activate()

#################################################################################

Procedure to run above python script,

Step1: Copy your weblogic.properties and create_JMS_Q.py        
           in <Middleware_Home>/wlserver_10.3/common/bin location. Where wlst.sh or wlst.cmd present
Step2: Run ./wlst.sh (if you install middleware in UNIX) or wlst.cmd (if you install middleware in 
            windows)

            ./wlst.sh create_JMS_Q.py
Step 3: When Username and Password asked that time you have to pass weblogic console username and password.

No comments:

Post a Comment