Showing posts with label wlst. Show all posts
Showing posts with label wlst. Show all posts

Friday, 10 June 2016

blogger

Failed to initialize the application "SB_JMS_Proxy_N7de264e1.N2efb99d.2.1553951a327.N7ffe" due to error weblogic.management.DeploymentException: Exception occured while downloading files

Hello Viewer,

Today i faced one issue while bringing up the OSB servers.Servers were not coming up. After reaching to Admin state it again went to force shutting down mode.

After seeing the logs i got the below error:

 <Error> <Deployer> <BEA-149205> <Failed to initialize the application "SB_JMS_Proxy_N7de264e1.N2efb99d.2.1553951a327.N7ffe" due to error weblogic.management.DeploymentException: Exception occured while downloading files
weblogic.management.DeploymentException: Exception occured while downloading files
        at weblogic.deploy.internal.targetserver.datamanagement.AppDataUpdate.doDownload(AppDataUpdate.java:50)
        at weblogic.deploy.internal.targetserver.datamanagement.DataUpdate.download(DataUpdate.java:59)
        at w
        Truncated. see log file for complete stacktrace
Caused By: java.io.IOException: [DeploymentService:290066]Error occurred while downloading files from Administration Server for deployment request "0". Underlying error is: "null"


Solution: Login to Admin console and goto deployments, search the ear for which you are facing the error, it should be in failed state.
It will not allow you to untarget this ear.just delete it from deployments and try to restart the server. This time servers should come up.

Thanks a lot for your patience!!!

Regards
-Ashish




Thursday, 26 May 2016

blogger

[OSB 12c] java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.bea.wli.sb.management.configuration.DelegatedSessionManagementMBean

Hello viewer,

I was trying to create the scripts for performing different operation on OSB like deployment , enabling/disabling of proxy, list out the deployed OSB service etc..
Although i have already created these scripts for 11g version of OSB but the jars which i used in shell script are not working in 12c.

In 12c below jar are not available: [snippet from .sh file]
--------------------------------------------------------------------------------------------------------
export CLASSPATH=$CLASSPATH:$OSB_HOME/Oracle_OSB/lib/sb-kernel-api.jar
export CLASSPATH=$CLASSPATH:$OSB_HOME/modules/com.bea.common.configfwk_1.2.1.0.jar
export CLASSPATH=$CLASSPATH:$OSB_HOME/Oracle_OSB/lib/alsb.jar
export CLASSPATH=$CLASSPATH:$OSB_HOME/Oracle_OSB/lib/sb-kernel-impl.jar
---------------------------------------------------------------------------------------------------------
when i tried to run the same script in 12c it was giving the error:

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.bea.wli.sb.management.configuration.DelegatedSessionManagementMBean


 Solution:

write below command in your shell script(.sh file)

a) MW_HOME="middleware home where osb is installed"
    export MW_HOME

b). $MW_HOME/osb/tools/configjar/setenv.sh

DON'T miss the dot(.) in above command

c) ${MW_HOME}/osb/tools/configjar/wlst.sh  ${DIR_EXECUTION}/proxytask.py

use wlst.sh from this location   ${MW_HOME}/osb/tools/configjar



Thanks a lot for your patience!!!

Regards
-Ashish

Monday, 23 May 2016

blogger

Script to enable and disable the proxy service in OSB

Hello Viewer,

Below is the script for enabling and disabling the proxy in OSB which may be required during any end system downtime or for just bouncing the proxy due to some issue like not picking up the messages from queue or any other one.

Note: This is for version prior to 12c.


Steps to be followed:


1) create a file ProxyOperation.py with below content:


------------------------------------------------------------------------------------------------------------------
import wlstModule
import sys
import os
import socket
from com.bea.wli.sb.management.configuration import SessionManagementMBean
from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
from com.bea.wli.config import Ref
from java.lang import String
from com.bea.wli.monitoring import StatisticType
from com.bea.wli.config import Ref
from com.bea.wli.sb.util import Refs
from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean
from java.lang import String
from com.bea.wli.monitoring import StatisticType
from com.bea.wli.config import Ref
from com.bea.wli.sb.util import Refs
from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean
project = sys.argv[1]
print('project name  is: ', project)
service = sys.argv[2]
print('service name  is: ', service)
action = sys.argv[3]
print('operation name  is: ', action)
connect('user','password','t3://AdminHost:Adminport')
domainRuntime()
print('WLST Connected')
sessionName = String("SessionScript"+Long(System.currentTimeMillis()).toString())
print('... after session. Session is: ', sessionName)
sessionMBean = findService(SessionManagementMBean.NAME,SessionManagementMBean.TYPE)
print('SessionMBean is: ', sessionMBean)
sessionMBean.createSession(sessionName)
print(String('Session was created ... ').concat(sessionName))
mbean = findService(String('ProxyServiceConfiguration.').concat(sessionName),'com.bea.wli.sb.management.configuration.ProxyServiceConfigurationMBean')
projectName = Refs.makeParentRef(project + '/')
proxyRef = Refs.makeProxyRef(projectName, service)
if action == 'disable' :
  print "Disabling " + service +" has been completed"
  mbean.disableService(proxyRef)
else :
  print "Enabling " + service +" has been completed"
  mbean.enableService(proxyRef)
if action == 'disable' :
  service1 = service+" disabled"
  print service1
  sessionMBean.activateSession(sessionName, service1)
else :
  service1 = service+" enabled"
  print service1
  sessionMBean.activateSession(sessionName, service1)
print
disconnect()
exit()
-------------------------------------------------------------------------------------------------------------------

Note: change the username, password and URL according to your environment.


2) Create a file ProxyOperation.sh with below content


--------------------------------------------------------------------------------------------------------------------
#!/bin/sh


export LOGFILE="/Mylocation/ProxyOperation/ProxyOperation.log"
if [ -f $LOGFILE ]; then
  rm -f $LOGFILE
fi
rm -rf /Mylocation/ProxyOperation/ProxyOperation.log
WL_HOME="wl_home"
export WL_HOME
OSB_HOME="osb_home"
export CLASSPATH=$CLASSPATH:$OSB_HOME/Oracle_OSB/lib/sb-kernel-api.jar
export CLASSPATH=$CLASSPATH:$OSB_HOME/modules/com.bea.common.configfwk_1.2.1.0.jar
export CLASSPATH=$CLASSPATH:$OSB_HOME/Oracle_OSB/lib/alsb.jar
export CLASSPATH=$CLASSPATH:$OSB_HOME/Oracle_OSB/lib/sb-kernel-impl.jar
echo "Please enter operation you want to perform"
read PARAMETER1
cd /Mylocation/ProxyOperation/
sh ${WL_HOME}/common/bin/wlst.sh  /Mylocation/ProxyOperation/ProxyOperation.py $1 $2 $PARAMETER1 >> /Mylocation/ProxyOperation/ProxyOperation.log

---------------------------------------------------------------------------------------------------------------------


Note: 
a) Mylocation: direcotry location where you will place the above files.
b) Change the wl_home and osb_home according to your environment.


How to run:


Suppose path of your proxy service is as below (you can find this path from sbconsole)

Proxy service path: MyServices/CustomerProduct/Services/ProxyServices/Source/PS_Customer_Service
here proxy name is   PS_Customer_Service

now the command to be executed is as below:
sh ProxyOperation.sh  <MyServices/CustomerProduct/Services/ProxyServices/Source>  <PS_Customer_Service>
press enter

Please enter operation you want to performtype disable/enable(case sensitive)
press enter

your proxy will get disable or enable depending upon the operation you specify.

Thanks a lot for your patience!!!

Regards
-Ashish



Tuesday, 10 May 2016

blogger

Script to create multiple workmanager in weblogic domain.


Hello Viewer,

I was asked to migrate the current weblogic resources to new weblogic domain as a part of upgrade project, among those weblogic resources there were around seventy workmanager with corresponding MaxThreadsConstraints.

I could manage to find the script on google for this task but only for single workmanager. So i tried to slightly tickle this script for managing this task of creating multiple workmanager with there corresponding MaxThreadsConstraints and MinThreadsConstraints in one go.

Below are steps to be followed.

1) Create a file with name createWorkManager.py with below content:

--------------------------------------------------------------------------------------------------------------
import sys
import os
import jarray
import dircache
from java.io import File
from java.io import FileInputStream
from java.lang import String

propInputStream = FileInputStream("details.properties")
configProps = Properties()
configProps.load(propInputStream)

domainName=configProps.get("domain.name")
adminURL=configProps.get("admin.url")
adminUserName=configProps.get("admin.userName")
adminPassword=configProps.get("admin.password")

totalWM_to_Create=configProps.get("total.WM")
#connection()
connect(adminUserName, adminPassword, adminURL)

edit()
startEdit()
print '======= Creating a WorkManager name as ======='
i=1
while (i <= int(totalWM_to_Create)) :

    try :
         cd('/')
         workManagerName=configProps.get("workManagerName."+ str(i))
         maxThreadConstraintName=configProps.get("maxThreadConstraintName."+ str(i))
         minThreadConstraintName=configProps.get("minThreadConstraintName."+ str(i))
         ServerName=configProps.get("ServerName."+ str(i))
         MaxThread=configProps.get("MaxThread."+ str(i))
         MinThread=configProps.get("MinThread."+ str(i))
         cd('edit:/SelfTuning/' + domainName + '/WorkManagers/')
         create(workManagerName,'WorkManagers')
         cd('edit:/SelfTuning/' + domainName + '/WorkManagers/' + workManagerName)
         cmo.addTarget(getMBean("/Clusters/"+ ServerName))
         save()
         print ' WorkManager Created...'
    
         print '======= Creating MaxThreadsConstraint ======='
         cd('edit:/SelfTuning/' + domainName + '/MaxThreadsConstraints/')
         try:
             create(maxThreadConstraintName,'MaxThreadsConstraints')
         except Exception:
             print 'Issue in Creating MaxThreads exiting'
         cd('edit:/SelfTuning/' + domainName + '/MaxThreadsConstraints/' + maxThreadConstraintName)
         cmo.addTarget(getMBean("/Clusters/"+ ServerName))
         set('Count',MaxThread)
         save()
    
         print '======= Creating MinThreadsConstraint ======='
         cd('edit:/SelfTuning/' + domainName + '/MinThreadsConstraints/')
         try:
             create(minThreadConstraintName,'MinThreadsConstraints')
         except Exception:
             print 'Issue In Creating MinThreads '
         cd('edit:/SelfTuning/' + domainName + '/MinThreadsConstraints/' + minThreadConstraintName)
         cmo.addTarget(getMBean("/Clusters/"+ ServerName))
         set('Count',MinThread)
         save()
    
         print '======= Assigning the MaxThreadConstraint to the WorkManager ======='
         cd('edit:/SelfTuning/' + domainName + '/WorkManagers/' + workManagerName)
         bean=getMBean('/SelfTuning/' + domainName + '/MaxThreadsConstraints/' + maxThreadConstraintName)
         cmo.setMaxThreadsConstraint(bean)
    
         print '======= Assigning the MinThreadConstraint to the WorkManager ======='
         cd('edit:/SelfTuning/' + domainName + '/WorkManagers/' + workManagerName)
         bean=getMBean('/SelfTuning/' + domainName + '/MinThreadsConstraints/' + minThreadConstraintName)
         cmo.setMinThreadsConstraint(bean)
    
         print '==> WorkManager Creation Finished ... Please Double Check from AdminConsole...'
    except:
        print '***** CANNOT CREATE Workmanager!!! Check If the Workmanager With the Name : ' , workManagerName ,' Alreday exists or NOT...'
        print ''
    i = i + 1
print '========================================='
save()
activate()
--------------------------------------------------------------------------------------------------------- 

2) create a file with name createWorkManager.sh with below content:

----------------------------------------------------------------------------------------------------------
#!/bin/sh

export LOGFILE="/Mylocation/createWM.log"
if [ -f $LOGFILE ]; then
  rm -f $LOGFILE
fi
rm -rf /Mylocation/createWM.log
WL_HOME="your weblogic_home"
export WL_HOME
cd /Mylocation/
sh ${WL_HOME}/common/bin/wlst.sh /Mylocation/createWorkManager.py >> /Mylocation/createWM.log
exit
-----------------------------------------------------------------------------------------------------------

Note: change wl_home and mylocation as per your environment and requirement. 

3) create a properties file with name "details.properties" which will have the details like below :

-----------------------------------------------------------------------------------------------------------
domain.name=DOMAIN_NAME
admin.url=t3://Adminhost:Adminport
admin.userName=username
admin.password=xxxxxxxxx

total.WM=2

ServerName.1=SOA_CLUSTER
MinThread.1=7
MaxThread.1=15
workManagerName.1=MyTestWorkManager1
maxThreadConstraintName.1=MyTestMaxThreadConstraint1
minThreadConstraintName.1=MyTestMinThreadConstraint1

ServerName.2=SOA_CLUSTER
MinThread.2=7
MaxThread.2=15
workManagerName.2=MyTestWorkManager2
maxThreadConstraintName.2=MyTestMaxThreadConstraint2
minThreadConstraintName.2=MyTestMinThreadConstraint2
---------------------------------------------------------------------------------------------------------------

Note:
a) total.WM = total number of workmanager you want to create.
b) Don't forget to add numeric suffix for every new entry.

4) Flow:

createWorkManager.sh ----> createWorkManager.py---------> details.properties

5) How to run :

a) Go to /Mylocation
cd /Mylocation/

b) execute the shell script:
sh createWorkManager.sh

Thanks a lot for your patience!!!

Regards
-Ashish

Sunday, 1 May 2016

blogger

Email Notification from ORACLE MFT 12C(12.1.3.0.2)


Hello Viewer,

For an efficient support it is always a smart choice to make the work easier and productive.Oracle has provided new tool ORACLE MFT to manage the file transfers. But in case of any failed transfer , our system should be well equipped with the method which can give us an alert rather than keep on monitoring the console and wasting most of the time in sitting ideal like zombie.  

ORACLE MFT has a build in feature of email notification for different kind of events.In this blog i  will provide you the steps to enable notification for few of the events.
This is two step process:
1) configure the email driver configuration.
2) Enabling event , creating contact and associating this contact with event.

Step(1) 

             1) Goto EM console
             2) Expand User Messaging Service.
             3) Click on usermessagingdriver-email (mft_server1)> click on Email Driver properties from                    drop down list.
             4) click on create and provide the details:
                  essential field that you should know is :>
                  a) Outgoing Mail Server, Outgoing Mail Server port
                  b) Default sender Address
                  c) Outgoing Username and password(Make sure this user should be there in your security                        realm)
             5) After providing all the values click on OK  and logout. Login again and see the updated                      values should be there.

Steps(2) 
          
               1) Login to you MFT machine(node) on which you have installed it.
               2) run the ./wlst.sh
               3) connect to your MFT server using connect() wlst command and execute the below wlst                        commands.

              a)  connect('username','password',t3://Adminhost:MFTserverPORT)

              b)  updateEvent('RUNTIME_ERROR_EVENT', true)

              c)   createContact('Email', 'ABD@host.com') 

              d)   addContactToNotification('RUNTIME_ERROR_EVENT', 'Email',            'ABD@host.com') 

Note: Here i have given example taking one of the event there are many other as well.

1) RUNTIME_ERROR_EVENT
               This event tracks the errors occurred at runtime. For example:
                               • Any errors that occur during the message processing 
                               • Server start errors 
                               • System event failure errors
2) DEPLOY_ARTIFACT_EVENT
This event tracks the artifact deployment events.

etc...

Restart the managed server and replicate any error scenario in MFT transfers and check if you are receiving email on email id: ABD@host.com

Thanks a lot for your patience!!!

Regards
-Ashish

Friday, 22 April 2016

blogger

 [12.2.1.0.0] Failed to start the BAM Alert Engine


Hello Viewers,

I was trying to configure the BAM Alerts with Email Notification feature. I created the BAM alerts in BAM composer and configured the BAM properties and user messaging driver.


while deactivating the alert I was getting the pop up saying "unable to deactivate the alert" but actually it gets deactivate. same behavior when i was trying to activate it.
When i was trying to save the alert it is "showing unable to load the alert"

In logs i was getting the below error:

-------------------------------------------------------------------------------------------------------------------------------------------------------------
<Apr 3, 2016 1:54:44 AM EDT> <Warning> <oracle.beam.server> <BEA-000000> <BAM Alerts Engine Service failed to start. 
Exception: java.lang.StringIndexOutOfBoundsException: String index out of range: 4 
at java.lang.String.substring(String.java:1963) 
-------------------------------------------------------------------------------------------------------------------------------------------------------------

Applied all the mandatory patches for BAM and restarted the server after clearing tmp, cache and data folder but still got the same issue.

Solution :

1) Go to EM -> Navigate to Business Activity Monitoring -> BAMServer -> BAM Properties
2) Click on "More Advanced configuration
3) Search for ScheduledDataPurgeTimeForDataObject property, change its value from 1:0:0 to 01:00:00
4) Save your changes.
5) Restart the environment.

Thanks a lot for your patience!!!

Regards
-Ashish

Sunday, 20 March 2016

blogger

Error while bringing up the server after changing the repository schema password in 12c 



Hello Viewer,

In my case business requires the Metadata Repository schema passwords to be changed on a regular basis.
I changed the password for all the repository schema but after changing the password as soon as i started the managed and Admin server , it was failing to restart.

Below was the error in logs:



Error Code: 28000
Mar 20, 2016 2:48:19 AM oracle.security.jps.internal.common.config.AbstractSecurityStore getSecurityStoreVersion
WARNING: Unable to get the Version from Store returning the default
oracle.security.jps.service.policystore.PolicyStoreException: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-28000: the account is locked


After checking with the database team MFT_OPSS account was getting locked.

Although I checked that except datasource we are not using the MFT_OPSS user anywhere else. But still again and again it was getting locked. From SQL developer also we were able to connect successfully and the same password was updated in datasource as well.

Cause:

A 12c Infrastructure uses a Java Platform Security (JPS) credential store. If the credentials in the JPS store do not match with OPSS schema credentials in the Metadata Repository, AdminServer and Managed server will fail to start.

Note: Above error applies to Oracle Fusion Middleware - Version 12.1.2.0.0 and later

Solution:

It was resolved after following the below steps:

1) I asked the database team to unlock the account and change the password for this user,

2)  Encrypted the password using below steps and updated the opss-datasource-jdbc.xml
         a) cd $DOMAIN_HOME/bin
             . ./setDomainEnv.sh

         b) java weblogic.security.Encrypt newpassword

3) $ORACLE_HOME/oracle_common/common/bin/wlst.sh

wls:/offline>modifyBootStrapCredential(jpsConfigFile='$DOMAIN_HOME/config/fmwconfig/jps-config.xml',username='MFT_OPSS',password='newpassword')

4) Try to bring up the Admin server and Managed server. Hopefully it will start without any error this time.

Thanks a lot for your patience!!!

Regards
-Ashish

Sunday, 3 January 2016

blogger

 

Script to target/untarget multiple datasource to/from the   cluster

Hello to Viewers,
This script will help in performing the target and untarget operation on multiple datasource in one go. You don't need to go to the console and do the same task manually which is of-course time taking and error prone.

FLOW:

shell script ---> python --> wlst command.


Here shell script will call python script and in python we have mentioned few relevant wlst command that perform the actual task.

Follow the below steps:

1) Create a shell script under below directory: QueueOperation.sh

I have taken the directory structure as below:

/opt/soauser/automation/SOADataSourceOperation/


DataSourceOperation.sh

----------------------------------------------------------------------------------------------


#!/bin/sh

export LOGFILE="/opt/soauser/automation/SOADataSourceOperation/DataSource.log"
if [ -f $LOGFILE ]; then
  rm -f $LOGFILE
fi
rm -rf /opt/soauser/automation/SOADataSourceOperation/DataSource.log
WL_HOME="/xxxxxx/xxxx/xxx/wlserver_10.3"
export WL_HOME
echo "Please enter target to Target and untarget to Untarget the Datasources:"
read PARAMETER1
cd /opt/soauser/automation/SOADataSourceOperation/
sh ${WL_HOME}/common/bin/wlst.sh /opt/soauser/automation/SOADataSourceOperation/DataSourceOperation.py $PARAMETER1 $1 >> /opt/soauser/automation/SOADataSourceOperation/DataSource.log
exit

------------------------------------------------------------------------------------------------

2) Create a text file in same directory that contains the datasource name:

Suppose you need to untarget the datasource related to SAP then name it as SAPdsList.txt(targetdsList.txt)

here target could be SAP or any end system to which datasources are related.

SAPdsList.txt
-----------------------------------------------------------------------------------------------------
DSNAME1
DSNAME2

------------------------------------------------------------------------------------------------------



3) Create a python file under the same directory: DataSourceOperation.py

Here i am assuming that 
datasources are targeted to only weblogic cluster.


DataSourceOperation.py

------------------------------------------------------------------------------------------------------
from java.io import FileInputStream

import java.lang
import os
import string
import sys , traceback

operation=sys.argv[1]
target=sys.argv[2]
def connectToServer():
        USERNAME = 'username'
        PASSWORD = 'password'
        URL='t3://AdminServerhost:AdminServerport'
        #Connect to the AdminServer
        print 'starting the script ....'
        connect(USERNAME,PASSWORD,URL)

def disconnectFromServer():
    print "Disconnecting from the Admin Server"
    disconnect()
    print "Exiting from the Admin Server"
    exit()
    print "Mission Accomplished"


def Target(DSName):
     try:
        print 'Entry point1...'
        edit()
        tgName = 'CLUSTER_NAME'
        startEdit()
        DSName = DSName.strip()
        print 'test0'
        cd ('/JDBCSystemResources/'+ DSName)
        print 'test1'
        set('Targets',jarray.array([ObjectName('com.bea:Name='+tgName+',Type=Cluster')], ObjectName))
        activate()
        print 'DataSource: "', DSName ,'" has been TARGETED TO CLUSTER Successfully'
     except :
        print 'Something went wrong...'
        exit()

def Untarget(DSName):
     try:
        print 'Entry point1...'
        edit()
        tgName = 'CLUSTER_NAME'
        startEdit()
        DSName = DSName.strip()
        print 'test0'
        cd ('/JDBCSystemResources/'+ DSName)
        print 'test1'
        set('Targets',jarray.array([], ObjectName))
        activate()
        print 'DataSource: "', DSName ,'" has been UNTARGETED FROM CLUSTER Successfully'
     except :
        print 'Something went wrong...'
        exit()

###############     Main Script   #####################################
#Conditionally import wlstModule only when script is executed with jython
if __name__ == '__main__':
    from wlstModule import *#@UnusedWildImport
print('This will enable you to perform operation on  datasource')
listName = target+'dsList.txt'
if operation=='target':
   f = open(listName,'r')
   out = f.readlines()
   for DSName in out:
     DSName.strip()
     print 'Trying to target  '+DSName
     connectToServer()
     Target(DSName)
     disconnect()
     print 'Target the '+DSName
else:
   f = open(listName,'r')
   out = f.readlines()
   for DSName in out:
     DSName.strip()
     print 'Trying to untarget '+DSName
     connectToServer()
     Untarget(DSName)
     disconnect()
     print 'Untargeted the '+DSName
disconnectFromServer()

-------------------------------------------------------------------------------------------------------

HOW TO RUN:

Simply run the shell script and provide the target system name as a parameter for ex:

cd /opt/soauser/automation/SOADataSourceOperation/

sh DataSourceOperation.sh SAP 

(here SAP is the target so python file will look for SAPdsList.txt)

then it will ask for the operation to be performed : Please enter target to Target and untarget to Untarget the Datasources

type the operation name and press "enter" and then verify the log file(DataSource.log) and queue status from console.

Thanks a lot for your patience !!!! 

Regards
-Ashish 

Friday, 4 December 2015

blogger

Script to Pause/Resume the multiple distributed queues at a time



Hello to Viewers,
This script will help in performing the pause and resume operation on multiple distributed queues in one go. You don't need to go to the console and do the same task manually which is of-course time
taking and error prone.

FLOW:

shell script ---> python --> wlst command.

Here shell script will call python script and in python we have mentioned few relevant wlst command that perform the actual task.

Follow the below steps:

1) Create a shell script under below directory: QueueOperation.sh


I have taken the directory structure as below:

/opt/soauser/automation/SOAQueueOperation/


QueueOperation.sh
---------------------------------------------------------------------------------------------------------------

#!/bin/sh

export LOGFILE="/opt/soauser/automation/SOAQueueOperation/Q_Pause_Resume.log"

if [ -f $LOGFILE ]; then
  rm -f $LOGFILE
fi
rm -rf /opt/soauser/automation/SOAQueueOperation/Q_Pause_Resume.log
WL_HOME="/xxxxxx/xxxx/xxx/wlserver_10.3"
export WL_HOME
echo "Please enter pause to PAUSE the queues or resume to RESUME the queues:"
read PARAMETER1
cd /opt/soauser/automation/SOAQueueOperation/
sh ${WL_HOME}/common/bin/wlst.sh /opt/soauser/automation/SOAQueueOperation/QueueOperation.py $PARAMETER1 $1 >> /opt/soauser/automation/SOAQueueOperation/Q_Pause_Resume.log
exit
--------------------------------------------------------------------------------------------------------------

2) Create a text file in same directory that contains the queue name:

Suppose you need to pause the queues related to SAP then name it as SAPQueueList.txt(targetQueueList.txt)

here target could be SAP or any end system to which queues are related.

SAPQueueList.txt
----------------------------------------------------------------------------------------------------------
QueueName1
QueueName2
----------------------------------------------------------------------------------------------------------


3) Create a python file under the same directory: QueueOperation.py

Here i am assuming that 
I  have 2 JMS servers : JMSSERVER1 and JMSSERVER2
My Managed servers name is MS1 and MS2
JMS module: JMSMODULE

QueueOperation.py
----------------------------------------------------------------------------------------------------------
from java.io import FileInputStream

import java.lang
import os
import string
import sys , traceback

operation=sys.argv[1]
target=sys.argv[2]
def connectToServerJMS1():
        USERNAME = 'username'
        PASSWORD = 'password'
        URL='t3://managedserver1host:managedserver1port'
        #Connect to the ManagedServer1
        print 'starting the script ....'
        connect(USERNAME,PASSWORD,URL)

def connectToServerJMS2():
        USERNAME = 'username'
        PASSWORD = 'password'
        URL='t3://managedserver2host:managedserver2port'
        #Connect to the ManagedServer2
        print 'starting the script ....'
        connect(USERNAME,PASSWORD,URL)

def disconnectFromServer():
    print "Disconnecting from the ManagedServer"
    disconnect()
    print "Exiting from the Managed Server"
    exit()
    print "Mission Accomplished"

def pauseQueueConsumptionJMS1(queueName):
     try:
        print 'Entry point1...'
        serverRuntime()
#       queueName = str(queueName.strip())
        queueName = queueName.strip()
        print 'test0'
        cd('/JMSRuntime/MS1.jms/JMSServers/JMSSERVER1/Destinations/JMSMODULE!JMSSERVER1@'+ queueName)
        print 'test1' 
        cmo.pauseConsumption()
        print 'Queue: "', queueName ,'" has been CONSUMPTION Paused ON JMS1 Successfully'
     except :
        print 'Something went wrong...'
        exit()

def pauseQueueConsumptionJMS2(queueName):
     try:
        print 'Entry point2...'
        serverRuntime()
        queueName = queueName.strip()
        print 'test2'
        cd('/JMSRuntime/MS2.jms/JMSServers/JMSSERVER2/Destinations/JMSMODULE!JMSSERVER2@'+ queueName)
        print 'test3'
        cmo.pauseConsumption()
        print 'Queue: "', queueName ,'" has been CONSUMPTION Paused ON JMS2 Successfully'
     except :
        print 'Something went wrong...'
        exit()


def resumeQueueConsumptionJMS1(queueName):
    try:
        print 'Entry point...'
        serverRuntime()
        queueName = queueName.strip()
        cd('JMSRuntime/MS1.jms/JMSServers/JMSSERVER1/Destinations/JMSMODULE!JMSSERVER1@'+ queueName)
        cmo.resumeConsumption()
        print 'Queue: "', queueName ,'" has been CONSUMPTION resumed Successfully'
    except :
        print 'Something went wrong...'
        exit()

def resumeQueueConsumptionJMS2(queueName):
    try:
        print 'Entry point...'
        serverRuntime()
        queueName = queueName.strip()
        cd('JMSRuntime/MS2.jms/JMSServers/JMSSERVER2/Destinations/JMSMODULE!JMSSERVER2@'+ queueName)
        cmo.resumeConsumption()
        print 'Queue: "', queueName ,'" has been CONSUMPTION resumed Successfully'
    except :
        print 'Something went wrong...'
        exit()

###############     Main Script   #####################################
#Conditionally import wlstModule only when script is executed with jython
if __name__ == '__main__':
    from wlstModule import *#@UnusedWildImport
print('This will enable you to perform operation on  distributed JMS Queues')
#connectToServer()
listName = target+'QueueList.txt'
if operation=='pause':
   f = open(listName,'r')
   out = f.readlines()
   for queueName in out:
     queueName.strip()
     print 'Trying Consumption Pause on '+queueName      
     connectToServerJMS1()
     pauseQueueConsumptionJMS1(queueName)
     disconnect()
     connectToServerJMS2()
     pauseQueueConsumptionJMS2(queueName)
     disconnect()
     print 'Consumption Paused on '+queueName
else:
   f = open(listName,'r')
   out = f.readlines()
   for queueName in out:
     queueName.strip()
     print 'Trying Consumption Resume on '+queueName
     connectToServerJMS1()
     resumeQueueConsumptionJMS1(queueName)
     disconnect()
     connectToServerJMS2()
     resumeQueueConsumptionJMS2(queueName)
     print 'Consumption Resumed on'+queueName
#exit()
disconnectFromServer()
#################################### 

---------------------------------------------------------------------------------------------------------

HOW TO RUN:

Simply run the shell script and provide the target system name as a parameter for ex:

cd /opt/soauser/automation/SOAQueueOperation/

sh QueueOperation.sh SAP 

(here SAP is the target so python file will look for SAPQueueList.txt)

then it will ask for the operation to be performed : Please enter pause to PAUSE the queues or resume to RESUME the queues

type the operation name and press "enter" and then verify the log file(Q_Pause_Resume.log) and queue status from console.

Thanks a lot for your patience !!!! 

Regards
-Ashish