03 May 2010

Adding preference properties in 11g

The main question to ask here is how to get and set the preference properies..?

Well, in SOA 10g versions , this was hardly a question. This was very simple and straightforward in 10g.
In 11g with weblogic server at core,  this is still simple, but not so straightforward.

Getting value of a preference property :

1. Create a composite with BPEL.

2. Go to composite.xml file.
Add a property with name as bpel.preference.myprop1 to the BPEL component definition and set value as 100


Note : The preference properties should always start with prefixes 'bpel' and 'preference' .
So name for a property ABC will actually be  bpel.preference.ABC


3. In the BPEL process, add a Assign activity and use the standard ora:getPreference function as in 10g
Assign activity code looks like this :



Note that even though the preference property name is bpel.preference.myprop1 , it is accessed using
ora:getPreference('myprop1'). Also remember to put single quotes as the funciton ora:getPreference expects a String input.


4. Deploy and run the composite. Instance will show that output variable has value as 100.

Setting value of a preference property :

1. Go to enterprise manager. Navigate to 'System MBean Browser' by right-clicking soa-infra > Administration > System MBean Browser

 
Note that this is for 11.1.1.1 . For R1 PS-1 or R1 PS-2 , this might be different

2. In 'System MBean Browser' page, search for a MBean with name "oracle.soa.config" and select the first search.Alternately, go to 'Configuration MBeans' > 'Application Defined MBeans' > 'oracle.soa.config'
Inside this Managed Bean, go to 'Server:soa_server1' > SCAComposite > Composite Name > 'SCAComposite.SCAComponent' > BPEL process name.
(BPELProcess1 in this example)



3.  MBeans are Java objects which  provide a way of managing resources. Each system MBeans's interface has 3 facades - Attributes for setting properties , Operations for methods that can be invoked on that MBean and  Notifications that can be used to send event alerts. Out of these the attributes  contain the preference properties.
 Click the property attribute to open the properties for this BPEL. On this page, preference property 'myprop1' will be visible.



4. Update the property to new value. Click 'Apply' and then 'Return' to go back to the attributes page.
New properties can also be added but keep in mind the naming standard.

5. After updating the property, go back to composite and test the process to verify the new value.
 
POC for the same can be downloaded from here.

Reading a properties file in BPEL

To read a properties file from BPEL, we can use Java Embedding.
In the java activity, we can read the property and assign the values to BPEL variables using 'setVariableData' function.

Lets have a simple POC to do the same :
1. Create a properties file say "TestProp.properties" and add some properties.


2. Create a simple composite with Async BPEL process and add a Java-embedding activity after Receive activity.

3. Open the Java embedding activity and add following code :



Note that the location for file is set in the first line.

4. Save and close the activity. Open the BPEL source and go to line where the Java embedding is present.
Add following Java import statements  before the code for java embedding activity.


<bpelx:exec import="java.io.*"/>
<bpelx:exec import="java.util.*"/>


After adding this , the code snippet looks like this :






5. Save, Deploy, Test.
Make sure that properties file is present and it actually contains the property 'myName'
Otherwise one needs to change the code a bit  to handle these scenarios. (Simply add a check to see if value is null)

Sample code for this POC can be downloaded from here .

28 April 2010

Creating Data Source in SOA 11g


1. Login to Application Server Console
2. Navigate to Home > Service > JDBC > Data Sources
3. Click "New".
4. Give the name and JNDI location for the data source.
5. Select Database using Database Type drop-down list. To create the data source
for Oracle's Database, keep the default value.
6. Select the database driver accordingly. If Database type is chosen as Oracle, default
driver is "Oracle's Driver(Thin XA) for Instance Connections" which supports global transactions.
To select driver for supporting local transactions, select "Oracle's Driver(Thin) for Instance Connections"
7. Click Next.
8. If a note for XA transaction comes, click Next.
9. Set the connection properties. Give Database name as the Service Name or SID so that
it automatically comes in the connection string
10. Fill host-name, user, password. Click Next
11. Click "Test Configuration" to test the connection. If the database name in step above was something different,
change URL appropriately.
12. Click Next. Select target servers on the screen that appears.
If you do not select any target, data source will not be deployed and you will not be able to use it.
13. Click Finish. Make sure that the Data source appears in the summary of data sources page.