Tuesday, March 06, 2012

Dynamic Adapter

Executive Summary

Most of the business processes in real time uses some integration with external systems.These integration may include interaction with file system, external database, external web services etc. In most of the case we do have an end point which may vary as per requirement.For example –Currently if you are using database A for storage of your data ,May be down the time you will like to use database B for storage of data.At that point of time you may need to change your code and redeploy the process in order to make the changes as required,This is a very lengthy process.Ideally an administrator should be able to do so by making some changes from the console without the use of redeploying the process.So here comes the concept that if we can desing our process in such a way that we can dynamically change the end point of a adapter then our purpose will be solved.

This article describes how to dynamically change the end point of an adapter taking the case of a file adapter.


Dynamic EndPoints in SOA Suite

Oracle SOA Suite provides the JCA architecure for technology adapter. Oracle JCA Adapters expose the properties specific to underlying back-end operations as header elements and allow the manipulation of these elements within a business process.
These properties can be changed from Em console of SOA Suite.
It contains support for following adapters:-
Oracle File and FTP Adapters,Oracle Socket Adapter,Oracle AQ Adapter ,Oracle JMS Adapter ,Oracle Database Adapter ,Oracle MQ Series Adapter

Need for Changing the Endpoint of Adapter Dynamically in SOA Suite

Technology is changing day by day.We can not expect that the same sort of input and output that will fulfill the reuirement of cosumer,With time the change needs to be done to the existing business process in order to fulfill the criteria required by the current generation.There comes the need for dynamically changing the end point.Let suppose we have a business process which write records to a certain file location in a machine A.Now there is a need to up grade the machine A as it is outdated.You can not stop your live business process because one of the end system is to be upgraded.At the same time you need to keep all the records that will be writteen by the adapter.There is one option that you can change the code of your business process to write in a different location and redeploy it.But again this will require a schedule outage of your business process which is not acceptable for a live business process.In that scenario the best option is to change the end points of the adapter dynamically.This can be done through console itself and it doesn’t requre your business process to be redeployed.

High-level solution

Oralce File adapter provides us the following JCA properties in its header metadata in inbound service.
jca.file.FileName: file name
jca.file.Directory: directory name
jca.file.Batch: a unique name for a batch in case of debatching
jca.file.BatchIndex: the batch index for each message within the batch for debatching

jca.file.Size: the file size
jca.file.LastModifiedTime: the last modified time for the file.

In our current scenario we will use the following header property “jca.file.Directory: directory name” to change the value of output directory dynamically in our Business Service.We will create a temporary variable and will assing the value of this variable to the header property “jca.file.Directory: directory name”.Once this process will be deployed,this property will come as a variable in em console and we can change the value dynamically from em console.


Solution details

The following section details out the setups required to recreate the problem scenario and then the solution steps.

Setups

SOA Suite 11.1.1.5
Oracle XE 11.2
RCU 11.1.1.5
Oracle WebLogic Server 10.3
Jdeveloper 11.1.1.5

Business flow

Steps to desing the process.

1. Create an OneWay BPEL process in Jdeveloper.



Assign it some Logical name



Now drag and drop a File Adapter in the right hand side of the Composite swinlane.This will cause a File configuration wizard to come up.


Call this adapter AdapterEndPoint


Let the default interface be there


Choose Write operation to write file


Provide some physical directory in your local machine and specify the name for the file.



For the schema of the message choose the input wsdl file itself



Say Next and Finish and your adapter configuration are complete.
Now join the BPEL process and the File adapter so that you should have a binding created for your adapter.IT should look like this.



Now go iniside your BPEL process drag and drop an invoke activity and make a connection between the invoke and the File adapter.
Drop an assign activity in between the receiveInput and the Invoke activity and and assign the input variable of the client to the input variable of the input variable of File adapter.


After completing this process your BPEL now should look like this.



Now our process is complete.We will deploy it to the server to check if it is working fine i.e. it is writing in to the specific file location.Once it is verified we will go ahead and make changes in our process so that we can change the end points of adapter dynamically.If the flow is working fine you should get following flow instance


Recovery

Now we will modify our process in order to change the adapter endpoint dynamically in the process.Go back to your Jdeveloper and go to the BPEL process that you have designed.

Create a variable with some logical name and make it a string variable.


Now assign some other file location to this new variable you have created.


Now go to your invoke activity,go to properties tab and then search for a property file called jca.file.Directory and in the value assign the new variable which we have created.




These are all the changes that we need to do in our process.Now we will rebuild and redeploy the process to the server.

Results
Now if you test the process with the setting specified above the file will now be written to the new file location that we have specified in our new variable.This means that the adapter properties have a preference over the hardcoded values in the process.We can desing our process so that the new variable can accept values from the client and then we can change the values dynamically.We can also have a rules/decision table where in we can already store the values of differenct location corresponding to some input values and thus can change the values dynamically.
Other than this we also have the feature of changing the value from em console.This can be done in following ways.First of all go back to your BPEL process and remove the changes that we have done for dynamically changing the value (Using a variable and then assigning its value to jca.file.Directory property)
Now Go to your em console.
Click on the process.In the right hand side in dashboard naviage till the bottom of the page,there you will get a property called a AdapterEndPoint as shown below click on that.



Now move to properties tab you will get the following properties file


As you can see we have one property PhysicalDirectory(Write).
You can specify the new location where you want to write your file and save the changes.Make sure the provided directory name already exist and save the changes.Now all the new instances which will get created will be written in the new location which you will specify in this property.

Further Scope

The Dynamic Adapter concept is limited to only technology adapter however for legacy and other adapters we can not use the same concept there we need to use another stricking feature of SOA Suite that is Dynamic PartnerLink.

Business benefits
You need not schedule and outage for the redeployment of your process, the end point can be changed dynamically at run time.


Conclusion
SOA Suite provide properties which can be used to change the end points of an adapter dynamically

Attachment:


IT contains the .jpr file for the project along with all the required artifacts.

Reproduce issue in local Machine

1>Download and unzip the file in your local machine.
2>Open your Jdeveloper and import the .jpr file in to jdeveloper.
3>Change the location of the file as per your local server file structure.
4>Deploy and test the process.

No comments: