Showing posts with label Example. Show all posts
Showing posts with label Example. Show all posts

Thursday, 11 August 2016

BPEL Headers and Preference Variable in 12c

                   BPEL Header and Config Parameters




BPEL Instance Headers


In BPEL we can see a name is always given to our instances. But to our ease of debugging we can provide a unique name or anything based on our requirement.

Lets think a BPEL process is executing an employee creation activity. Now if wont set any name it will be hard to debug and we need to open each and every instance to see which instance has created our employee.

Now we just set like 'Employee Creation For ' + name of employee as instance name then it will be easy for us search for this instance and we can easily find out during the debugging.


In the BPEL create an assign activity and then a small code can make your job. These are steps you need to take


Few things to be note down in 12c.

1. In oracle soa 12c there is bug,  due to which ora:setCompositeInstanceTitle does not work.  Its a known issue to oracle.

2. Oracle has given a patch for this issue and patch number is 20423408. You need to download this bulky patch and then need to run given below commands to run the sample.


Patching 

1. Run the cmd prompt in admin mode. Set Oracle Home, for its in the 12cBPM folder
      SET ORACLE_HOME=C:\Oracle\12cBPM\Middleware\Oracle_Home


2. Now set Opatch path.
     SET PATH=%PATH%;C:\Oracle\12cBPM\Middleware\Oracle_Home\OPatch

3. Now go to the folder where you unzip your patch like i downloaded to the location.
     C:\temp\patch\p20423408_121300_Generic\20423408

4. Now run the opatch command
   opatch apply

Once done remove system folder in your machine and then start server.


ora:setCompositeInstanceTitle  Deprecation

    Oracle has depricate the function ora:setCompositeInstanceTitle and a new function oraext:setFlowInstanceTitle has come to replace it.


Steps  to use.


1. Add a assign activity in your process. Double click it and then assign a function


2. Choose any ouput variable and assign a function to it and choose the function ora:setCompositeInstanceTitle() from the Advance functions.


 3. Now use any variable inside the function, you can very much compare it as a System.out.println()      give any string and it will set it as a instance title.  I have chosen employee Name as title name.




4.  To make it more meaningful you can concat different information for title like

oraext:setFlowInstanceTitle(Concat('EmpCreatoin For : ', $inputVariable.payload/client:customerName))



Now before running this process lets discuss one more topic which is small but very highly used in all the BPEL projects. This is about the config parameters.


Preference Variable

 Preference Variable  you can think about the program constants, as these are been used multiple times in our program, instead of hard-coding them in all the places we can create them in the composite and other places we can simple use them.


  Only issue here is these config parameters are on BPEL level not on composite level, Hence if you want to use same constants in two BPEL you have to declare them individually.

Now how to create a preference variable.

1. Open the composite and go the BPEL component and add the property, as given below


     <property name="bpel.preference.ERROR_STATUS">ERROR</property>
    <property name="bpel.preference.SUCCESS_STATUS">SUCCESS</property>
    <property name="bpel.preference.TITLE">Employee Creation</property>



2.  Now in BEPL any where you need these variables you can simple access using the ora:getPreference() method. Like you need to get the value of the title then you can simple write 

ora:getPreference('TITLE')







 If we combine both then in our assign activity we can simply change .

        oraext:setFlowInstanceTitle(Concat("EmpCreatoin For : ", $inputVariable.payload/client:customerName))

to

        oraext:setFlowInstanceTitle(concat(ora:getPreference('TITLE') , $inputVariable.payload/client:customerName))



Hope you like the blog, we are happy to take your ideas to make it better.




Running 

 Now you can run the process to see the title and also, just provide any simple name for customerName and address and then you can see the instance title.






Download Example : 


Download example from the link : Example

direct Link https://drive.google.com/open?id=0B13Nkwu-4qVDRkFUM20zbHl3aFE



Play

1) Create 2 more preference variable and set them as a title and see the deployment.

2) Create 2 preference variable assign values 5 and 4 and there multiplication assign to output.




Reference
https://cloudipaas.wordpress.com/2015/06/08/soa-suite-12c-patchset-20423408-soa-12-1-3-0-2-bundle-patch-how-to-apply-patch-on-windows/
 

Special Thanks

  Ankur and Sagar to find me patch :-) and numerous suggestions.




Monday, 16 May 2016

Oracle SOA 12C - File Adapter

File Adapter 


Its one of the simplest adapter in the Oracle SOA suite and we are going to take this adapter for 

1. Reading file.
    a.  Initiator Process
    b. Sync Read.

2. Writing file 
   a.   New File
   b.  Appending a file.




This example illustrate both the example of reading a file and writing a file. We will also focus some of the out of box options this adapter provides.  This adapter also follow the JCA pattern, to learn more about adapter design pattern see our last blog.


1. Reading File :- 

  We are using this option to read the file and get the data inside the SOA process, for processing.  There could be two different ways of reading the file first, our process is live and polling on single or multiple directories and once it found the file it process the file and either delete or archive the file(s).

 Second option is sync read which provide us a choice to read the file from a directory when we want. In this case we can read like in the middle of a SOA process.

Download Activity2.zip file and open this, This is a very simple application with file reading capability.


 a. In this example we are reading simple xml file and counting the records. Testfiles are been put in the testsuit directory.

  Here are some steps to configure file adapter


    a. In the Composite drag and drop file adapter to partner link, it will start the wizard.  Give any name to your file adapter.


b. Lets accept default for next 2 screens.


c. Now we want first to read file choose for read operation. We are going to discuss all the other operations in some others blogs.


 d.  Now choose a directory where you will upload the files.


e. Provide the pattern of your files, we have selected to upload files of all kind of names but you can choose any single type.


f. Now decide on polling frequency on the folder, composite will keep on checking folder with this frequency.


g. Now we have used the employee.xsd as the schema for the file. We have already described about this xsd in one of your earlier blog.



 h. Now file adapter is configured.




In the example given we are initiating a BPEL process from the file adapter, hence once its read the file successfully it initiate the BPEL process.


 Testing Adapter 

   1. Once we add a file from the testsuite to destination folder it process the file automatically and create the instance.

  
 2. Instance can very much self expalnatory that it initiate the BPEL and provide inputs to file BPEL process.
 3. This screenshot describe the inputs we received from the file adapter.





 Play with this example, try to change configurations and see what change can make it behave differently. We are going to share some other technique with file adapter very soon.