Set/Get
Preference Property and change it on runtime from Oracle EM
Basically
it is like a variable whose value we can change from EM console without doing
any code change.
These preferences are worked as variables which we can change at runtime from EM console.
Set Preference property in Composite.xml: First of all you need to define Preference property in Composite.xml file.
Open Composite.xml file in source mode.
Add Preference property in inside
Component section. for ex I am using it for Email so my property name is
"bpel.preference.Email", you can give it any name as per your
requirement.
bpel.preference.{CustomName}
<component name="CustomerNotification">
< implementation.bpel src="
CustomerNotification.bpel"/>
< property
name="bpel.config.transaction">required</property>
< property
name="bpel.config.oneWayDeliveryPolicy">sync</property>
< property
name="bpel.preference.Email">test@test.com</property>
</component>
SOA - Using ora:getPreference() in BPEL process to get
Environment specific Values
There are scenarios, when we have SOA
Services (Composites), which uses Environment specific data in the transaction.
Development DEV
Test TST
Production PRD
ora:getPreference('environmentName')
Here 'environmentName' is variable name.
There are cases where we need to change the values of the variables dynamically with in the same environment at runtime or while deploying the services from one environment to the other in order to accomplish this we have a concept called Preference Variables
We can create a preference variable in the
Compiste.xml one’s the service is deployed we can change the value of the
preference variable in the EM at runtime and the changed value will be
reflected immediately
dvm:lookupValue
The
dvm:lookupValue function returns a string by looking up the value for the
target column in a domain value map, where the source column contains the given
source value.
Syntax:
dvm:lookupValue(dvmMetadataURI as string, SourceColumnName as string, SourceValue as string, TargetColumnName as string, DefaultValue as string) as string
adf-config.xml
file In SOA
The common adf-config.xml file can be used
to deploy all the composites instead of using the adf-config file from the
individual composite applications.
The adf-config file configurations can be changed at runtime through ant script to deploy the composites to different environments.
Create
a Build.properties file for each environment and specify the MDS details as
mentioned below.
oa.partition=soa-infra
db.user=SOA_MDS
db.password=xxxx
Preferences in SOA composite / Deployment Descriptor
"These preferences are worked as variables whose value can be changed at runtime from EM console without any code change."
We can use these variable for email address and file locations (usually these values will get changed based on the environment)
Step1:First of all you need to define Preference property in Composite.xml file.
Open Composite.xml file in source mode.
Add Preference property in inside Component section.
bpel.preference.{CustomName}
<property name="bpel.preference.Email">test@test.com</property>
Step2: Use this preference property inside BPEL.
To use this property inside BPEL you need to use
ora:getPrefernce("CustomName") function.
ora:getPreference('Email')
Step3:Update preference property value in EM console.
We can update this property from MBean Browser inside EM console.
Go to EM console (http://host:7001/em)
Navigate to "Farm_base_domain" -> "Weblogic Domain" folder -> Right click on your domain -> "System MBean Browser"
Go to "oracle.soa.config" -> "soa-server" -> "SCAComposite" -> Choose your composite
Then navigate to "SCAComposite.SCAComponent" -> your component name -> Click on "properties"
Now you can see all the preference properties that you defined in your composite. You can change preference property value here.
Q) What is getPreference property? How do we set it and what advantage it provides?
Hard coding is not a good practice, so to avoid hard coding preference variables can be used and the value of the preference variable is accessed using getPreference(). The preference variable value can be changed without redeploying the code via em console MBean property.
getPreference:
"Basically it is like a variable whose value we can change from EM console without doing any code change."
composite.xml :
"<property name=""bpel.preference.BASE_COMPOSITE_TITLE"">INT0001.0_ProjectTask_</property>"
assign activity:
ora:getPreference('BASE_COMPOSITE_TITLE')
$gCompositeTitleBase_Var
currentDateTime:
assign:
xp20:current-dateTime() $gCurrentDateTime
Handle Dynamic Parameter using bpel.preference Property:
"to change variable value dynamically without re deployment of your composite then bpel.preference is one of the option that you can use.
Steps:
1. Create a SOA project with BPEL component.
"2. Open composite file in source view and add below property
inside component section."
<property name=”bpel.preference.gLanguage”>ODI</property>
3. Add a Assign activity use ora:getPreference(“gLanguage”)
"to fetch value of preference variable and assign that to variable created in bpel."
4.Changing the Preference value from EM console
Right click on SOA-Infra –> Administration –> System MBean Browser.
Go to your composite using this path oracle.soa.config–>
soa_server SCAComposite–>Project1–>SCacomponnt.SCAComposite–>BPELProcess1.
"Click on the properties tab on the right hand side and expand properties tab to
find out element contains your defined preference variable"
Change its value and click “Apply”.
No comments:
Post a Comment