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



1 comment:

  1. Raffles - MGM, Inc.
    The Raffle takes place in 삼척 출장안마 the heart of Reno with 3 winners from 충주 출장샵 across the country competing to win 대구광역 출장마사지 an amazing prize! 제주 출장샵 There are three ways to win: a $50 경주 출장샵 slot prize wheel and a $100

    ReplyDelete