Antony Reynolds
Fusion Middleware Roadmap
Throttling Files
Throttling Files
I'm sure everyone has been tempted to grab a file by the throat and squeeze it until it departs for that great filing cabinet in the sky, but that is something to discuss quietly with your psychiatrist. In this entry I would like to investigate how to limit the concurrency of file handling procedures.
A Concurrency ProblemBy default the interaction with the file adapter is a one way interaction. The file adapter posts a message into the queue for a process and then carries on about its business. This is good because it allows multiple files, or multiple batches from a single file to be processed concurrently. However if there are a large number of concurrent processes started then this can cause performance problems as the process manager starts to worry about which process to execute when. One sympton of this is undelivered messages visible on the BPEL console.
This is bad because it means we are feeding BPEL process manager faster than it can consume, and so it gags a little and throughput is reduced as it gags.
Stopping Force FeedingSo how do we tell the file adapter that BPELs mouth is full and please wait until I have eaten this bit. Well the answer is in the observation that interactions with the file adapter are usually one way. They do not need to be! It is possible to modify the WSDL generated by the file adapter wizard to support a two way interaction. This causes the file adapter thread to wait until the reply before sending another message. For the reasons why changing from a one-way to a two-way interaction causes this behaviour look at my earlier entry on BPEL threading. The answer is left as an exercise to the reader.
Changing the File Adapter WSDLTo change the one-way interaction to a two-way interaction we do the following in the generated WSDL file:
- Make sure that the definitions root element has a namespace reference to XML schema by adding the following
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- Add a dummy message that will be used in a reply.
- <message name="Dummy_msg">
<part name="PhoneRecords" type="xsd:string"/>
</message> - Add a reply to the read operation
- <output message="tns:Dummy_msg"/>
- Add a reply to the binding
- <output/>
<definitions
name="ReadPhoneBookFileSvc"
targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/ReadPhoneBookFileSvc/"
...
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
...
<message name="PhoneRecords_msg">
<part name="PhoneRecords" element="imp1:PhoneRecords"/>
</message>
<message name="Dummy_msg">
<part name="PhoneRecords" type="xsd:string"/>
</message>
<portType name="Read_ptt">
<operation name="Read">
<input message="tns:PhoneRecords_msg"/>
<output message="tns:Dummy_msg"/>
</operation>
</portType>
<binding name="Read_binding" type="tns:Read_ptt">
<pc:inbound_binding />
<operation name="Read">
<jca:operation
...
OpaqueSchema="false" >
</jca:operation>
<input>
<jca:header message="hdr:InboundHeader_msg" part="inboundHeader"/>
</input>
<output/>
</operation>
</binding>
...
</definitions>
Modifying the BPEL ProcessHaving modified the WSDL we must modify the BPEL to now do a reply. The reply will release the file handling thread in the adapter to do further work. The modified process is available as project BigBatchProcess1.2 in the FileManipulation.zip file. Details of using this process can be found in an earlier entry on batch processing of files. Note that there is an additional test file included in the src directory - phonebook2.csv - that has 5000 records in it to give a larger test case.
Other ScenariosThe above scenario is not the only one where we may wish to use a two-way interaction with the file adapter. The following additional scenarios may also occur.
Reading a File SequentiallyWe may need to process a file in strict record order yet still want to have it batched because it is a large file. In this case the problem is that we may have multiple batches submitted concurrently and there is no guarantee of the order that they will be processed in. In this case just making the interaction two-way is not enough because there may be more than one file processing thread.
Controlling the Number of File Processing ThreadsThe number of threads used to process files in the file adapter is controlled by a setting in the file $ORACLE_HOME/bpel/system/services/config/pc.properties. To alter the number of threads change the following property:
- oracle.tip.adapter.file.numProcessorThreads=1
Processing Files in Date OrderAnother scenario where these techniques are applied is when there is a requirement to process files in order of last modification date, for example when later files may contain reversing transactions for earlier files. This can currently only be achieved in 10.1.3.1 via a patch but it should also be available at some point in 10.1.3.3 and later releases.
Final ThoughtsThe use of two-way interactions and limiting threads processing files is very powerful but it needs to be considered in the context of other file interactions in the system. One way to limit the impact is to use singleton processes to receive the processing requests, enabling messages to be queued in order, releasing the file processing threads for other processes to use whilst still ensuring correct ordering in the required processes.
Hope this helped.
More on Batch Processing in BPEL
More on Batch Processing in BPEL

A Use CaseThe process needs to refresh the corporate phone book. It does this by reading a file with the new phone details, deleting the old phone details from a database and then inserting the new phone details into the database.
A file is read into the process via ReceivePhoneBook activity. The ClearPhoneBook activity uses custom SQL to truncate the phonebook table. Finally after transforming the file format to database format the new phone details are inserted into the table using the InsertIntoPhoneBookActivity to insert multiple records into the table in a single call.
A Fly in the OintmentThis process works fine as long as all the records are received in a single message. If they are received in multiple messages then not all the records will be written as multiple processes will receive part of the input file, but all the processes will truncate the table, resulting in the possibility of some records being inserted by one process and deleted by another process that starts a little later. This is illustrated in the diagram below which shows three processes each processing a portion of the file.

Note that records 1-10 are written to the database at the same time as the table is truncated by the process receiving records 11-20, leaving the possibility that the write will complete only to be overridden by the truncate. If records 1-10 are not overwritten by the second process they will definitely be overwritten by the third process which only starts truncating the table after records 1-10 have been inserted into the table.
A SolutionWhat we need to do is to separate the deletion of the existing data from the insertion of the new data. We can do this by moving the truncation of the table (deleting the existing data) into a separate BPEL process. Such a process is shown below.

For this to work we need to know when a new file starts to be loaded so that this process can be invoked before any record processing is performed. Now there are lots of complicated ways that we could do this with singleton processes to maintain state and complex logic to make sure it all works. Or we could use a newish feature of the BPEL process manager (introduced in 10.1.3.3 I believe) to get it to invoke our process.
Batch Manager
In the previous discussion I ignored the partner link that initiates the record deletion process. This partner link implements the Batch Manager interface as specified in $ORACLE_HOME/bpel/system/xmllib/jca/BatchManager.wsdl. To create the above process first create a new empty BPEL process and then in the services stream right click and select new partner link. Click on the
- onBatchReadStart - tells when a file is started to be read
- onBatchReadComplete - tells when a file has finished being read
- onBatchReadFailure - tells when a record or records cannot be processed by the adapter framework
Who to Tell?How does the BPEL Process Manager know to call the notification process? The answer is that it is configured as an activation agent property in the bpel.xml file of the process receiving the records from the file adapter. To set up the notification it is necessary to add the following property tag to the bpel.xml at XPath location BPELSuitcase/BPELProcess/activationAgents/activationAgent :
- <property name="batchNotificationHandler">bpel://default|FileNotificationProcess</property>
Final StepsWith notification configured we now need to modify our BPEL process to not truncate the table because this is being done via a separate process. We also need to add a delay to the process to avoid race conditions that could cause records to be inserted into the database before the database has been truncated. The modified process is shown below, complete with a 30 second delay to avoid problems with multiple processes being invoked at the same time.

A Worked ExampleI have created a sample to let you explore how all this works. To set it up do the following.
- Download the project files in FileManipulation.zip.
- Unzip FileManipulation.zip - this will create a FileManipulation directory with 3 sub-directories and a JDev 10.1.3.3 workspace
- Open the workspace FileManipulation.jws in JDev 10.1.3.3
- Create the following directories or modify the file adapter partner links in BigBatchProcess1.0 and BigBatchProcess1.1
- C:FilesInbound
- C:FilesOutbound
- Create a test user in the database by running the script in FileManpulation/BigBatchProcess1.0/src/CreateUser.sql as a system user
- Create a database connection in JDev called TestDS to connect to user Test (password test) in the database. You may need to rerun the adapter wizard if you are not running XE database on port 1521
- As user test run the script in FileManpulation/BigBatchProcess1.0/database/CreateTable.sql to create the phonebook table.
- Deploy the BigBatchProcess1.0 to the BPEL process manager.
- Test it by copying file FileManpulation/BigBatchProcess1.0/src/PhoneBook1.csv to C:FilesInbound.
- Verify the number of records stored by executing command in database "select count(*) from phonebook. There are 1000 records in the source file, you will probably receive a count less than 1000 due to race conditions around truncating the table and inserting records into it. This is the problem we are trying to avoid.
- Deploy the BigBatchProcess1.1 to the BPEL process manager as version 1.1.
- Deploy the FileNotificationProcess1.0 to the BPEL process manager.
- Test it by copying file FileManpulation/BigBatchProcess1.0/src/PhoneBook1.csv to C:FilesInbound.
- Verify the number of records stored by executing command in
database "select count(*) from phonebook. There are 1000 records in
the source file, you should now receive a count of 1000 in the database table, indicating thqat we have solved the problem.
- Pat yourself on the back and have a nice drink.
Register of Interest
Register of Interest
Lets start by looking at what a registry is.
Glorified Yellow PagesUncharitably a registry may be described as a glorified yellow pages. It allows artifacts such as XML schema and service WSDLs to be stored in a searchable, categorized archive. Artifacts are stored under different categories and may have keywords associated with them to assist in searching. So at the end of the day the registry is just a repository of meta-data about artifacts. In the same way a car is just a large amount of beaten metal with a power unit that drives wheels. Calling it a repository of meta-data does not actually explain what it does or how it may be used.
Registry use CasesLet me suggest a few registry use cases
- Design Time Service Discovery
A registry can be used to catalogue existing services and associated artifacts. This encourages re-use by making it easier to discover existing services. The ability to promote items between registries also makes it possible to put in place a service approval process that vets new services before making them available to developers. This again promotes re-use and generalisation of existing services. - Run Time Service Discovery
A registry can also be used at runtime to provide the physical endpoint for a service. This makes it easy to change the physical provider of a particular service. This also simplifies migration of services between development test and production environments as outlined in the next use case. - Service Migration Mechanism
The use of multiple registries provided a managed path for services to be promoted between environments, either from a development perspective or from a runtime perspective.
Run Time ConsiderationsUsing a registry in a runtime environment promises a greater degree of de-coupling. However a similar amount of decoupling may be achieved through the use of an ESB alone. If a registry is used to look up an ESB endpoint then there is a potential cost to be paid in terms of an additional lookup. If an ESB endpoint is not looked up then there is the risk of coupling the data formats of unrelated services together, losing the use of an ESB to provide message transformation to/from canonical form. Some informal tests I ran indicated that the additional overhead of a registry lookup does not add much to the service invocation, but in high volume environments it may be the straw that breaks the camels back.
A good policy may be to begin using a service registry in design time, later trying it out in non-high volume environments. Using an ESB can make this migration to registry use easier, if less pure by having the ESB perform the registry lookup.
Using a Registry with Oracle BPEL PMThe current production release of Oracle BPEL PM has built in support for use of a registry. Al that is required to make a service lookup occur through a registry is to perform the following.
- In the BPEL Console, go to the "Manage BPEL Domain" and set the following properties
- uddiLocation - the inquiry address of the registry
- uddiUsername - if it is a secured registry set it to a username for performing lookups, if not set it to urn:unknown
- uddiPassword - if it is a secured registry set it to a password for performing lookups, if not set it to urn:unknown
- In a BPEL process for each service endpoint (partner link) that you want to go through a UDDI lookup
- Add a property "registryServiceKey" to the partner link with the "Entity Key" value assigned in the UDDI repository
An Example of Dynamic LookupTo give a feel for dynamic lookup I have uploaded 3 JDeveloper Projects in the this file.
- JavaWS includes a simple Java web service (GreetingWS) that can be registered in a service registry. When registering it in the registry you will need to note the service key and copy it into the partner link property in Dynamic BPEL.
- DynamicBPEL is a BPEL process that looks up the web service (GreetingWS) and invokes it in three different ways
- Static, it uses the endpoint defined in a WSDL file
- Dynamic, it sets the endpoint explicitly (passed in as a parameter to the process), showing how you can be very dynamic in the endpoint you invoke.
- UDDI, it uses the UDDI repository to lookup the endpoint, showing how unintrusive it is on the rest of the process.
- TestDynamic is a BPEL process that you invoke to test the DynamicBPEL process. It iterates over all three methods and calculates how long each method takes to complete the given number of iterations. The first invocation is not counted to allow the system to "warm up" for each call.
More on Time!
More on Time!
In the fragment below I take the input data from XPath expression /DateList/SingleDate/DateField. This has the date in format MM/DD/YYYY. I use this input to populate an element dateitem which is of dateTime type.
Lets go throught the XSLT a little at a time.
<dateitem>
<!-- Parse Date of format MM/DD/YYYY -->
<!-- I declare a variable TempInput to hold everything after the first '/' in the date (DD/YYYY). -->
<xsl:variable name="TempInput">
<xsl:value-of select='substring-after(/DateList/SingleDate/DateField,"/")'/>
</xsl:variable>
<!--I set a variable Month to hold the month, generated by picking up everything before the first '/' in the date (MM). -->
<xsl:variable name="Month">
<xsl:value-of select='substring-before(/imp1:DateList/imp1:SingleDate/imp1:DateField, "/")'/>
</xsl:variable>
<!--I define a variable Day to hold the day portion which I get by picking up everything before the '/' in my Temp variable (DD). -->
<xsl:variable name="Day">
<xsl:value-of select='substring-before($TempInput, "/")'/>
</xsl:variable>
<!--I then pick up everything after the '/' in Temp variable (YYYY) and put it in a Year variable. -->
<xsl:variable name="Year">
<xsl:value-of select='substring-after($TempInput, "/")'/>
</xsl:variable>
<!--Finally I construct an XML dateTime format by concating the Year, Month and Day variables in the correct XML format. -->
<xsl:value-of select='concat($Year,"-",$Month,"-",$Day,"T00:00:00")'/>
</top:dateitem>
Obviously the parsing could be made to handle time formats and timezones as well.
Hoping that this helps someone struggling with parsing text strings into dates.
I have created a simple ESB project that takes data from a file in US date format and loads it into two columns in a database table, one formatted as a string the other as a SQL Date. When using the Database adapter the SQL Date format gets converted to an XML dateTime. The project is available for download here.
BEA Completes
BEA Completes
Now that the bean counters have had their fun it is the engineers turn. Although individual products will continue to be supported it will be exciting to see a convergent road map for Fusion Middleware, WebLogic and AquaLogic. Both companies invested heavily in standards based computing and so there are lots of opportunities for convergence and synergies between the product stacks.
The acquisition of BEA also gives Oracle access to a whole new set of contacts within their customer base. Although Oracle and BEA have a large overlap in their customer base they tend to talk to very different parts of the business. The combination of both companies will open up new opportunities for existing Oracle product lines as well as for the newly acquired BEA product lines.
The next few months will be very interesting times.
Finding the End(point)
Finding the End(point)
A Tale of Two WSDLsWhen you build a new BPEL process, you generally end up with a new WSDL file that defines the inputs and outputs of the BPEL process. What this WSDL file is lacking however is any endpoint information. Endpoint information details the logical network name and port number of the server on which the process is running, as well as the path to the process. This data cannot be filled in until the process is deployed to a specific domain (part of the path of the request) and server (hostname and port number part of the request). Hence when retrieving the WSDL from the JDeveloper file, you have no location where the process is available and it is this lack of data that the ADF wizard complains about. When you retrieve the WSDL from the BPEL server then it includes the location information of the process and hence the ADF wizard is happier.
Obvious when you think about it, but it is a problem that plagued many people in the past so I thought I would share it with you.
Patterns and Methods
Patterns and Methods
Methodologies
The Oracle SOA Success Methodology is a methodology with a small 'm'.
It is best viewed as a set of tools of techniques that can be applied
within the context of a more proscriptive methodology. That said it
works best with iterative methodologies.
The SOA Success Methodology is currently used with a restricted number
of Oracle customers prior to a full release.
Within the context of the SOA Success methodology is extensive
modelling of the business in terms of services. Oracle BPA Suite can
be used to drive this iterative modelling process.
BPA encourages a focus on the abstract modelling side of the SOA
success methodology. As the model becomes more reified then composite
services and processes may be made available to JDeveloper through a
shared repository.
Oracle is currently using BPA Suite to perform high level modelling in Fusion Applications development.
BPA Suite supports roundtripping to allow regeneration of processes
without loss of reifications applied to earlier versions, encouraging
an iterative cycle between business analyst and process developers.
SOA Patterns
Best source for SOA patterns in the Oracle space specifically is the BPEL cookbook
which covers a lot of common patterns and techniques. Both the latest
release of Oracle SOA Suite 10g, and 11g currently in beta, encourages
these best practises in a number of ways, including but not limited to
the following.
- Rules abstraction for
- True Business Rules - tight integration of rules and BPEL
encourage business process developers to abstract business logic into
the rules engine - this is also available in 10g
- Routing Rules - tight integration of rules and Mediator encourage developers to abstract routing decisions into the rules engine
- Service Abstraction
- Encourages service level location abstraction by making it easy to hide physical endpoint of service - in 11g all BPEL processes are automatically packaged up in the same SCA assembly used to describe service deployments
- Encourages service level interface abstraction by encouraging use of mediator to transform between canonical and physical implementation formats
- Process Abstraction
- Definition of processes allows for lower level processes to be treated as services
- Capturing of process flows in code allows for simulation and modelling based on real world data
- Human workflow captures common best practise human interactions into re-usable templates
- Process Migration
- Champion/challenger processes - two versions of same process can run in parallel and be compared to see which yields best results based on concurrent versioning capabilities of BPEL process manager.
- Managed process migration - ability to run multiple versions of
same process allows controlled introduction of new process versions
whilst existing instance continue to execute.
- Service Discovery
- Service promotion - use of a registry allows services to be promoted from dev to test to production in a managed way, encouraging best practise.
- Service catalogue - use of UDDI allows such a catalogue to be
maintained to encourage re-use by simplifying service discovery process
Of Laundries and Lego
Of Laundries and Lego
SOA is about ServicesIt might seem obvious but service orientation is about changing your thinking (orienting yourself) to think about IT systems as a collection of well defined collaborating components (services). A service has some sort of contract implying that the consumer of the service will provide X and in return will get Y. A laundry is a great example of this. A laundry defines an interface, I prefer to think of it as a basket, that says you give me a basket of dirty laundry and some money and I will give you a basket of clean laundry.
The Service Interface
The basket interface, defines that laundry is passed in a basket or a bag, and has various options (lets call them parameters) that allow the client to specify if they want stain removal on particular items, or if they want their laundry starched, or repaired or any of a number of different options. Note that these parameters specify what is to be delivered, not how it is to be done. In SOA we may use WSDL and XSDs to define the interfaces.Composite ServicesOur laundry service provider may decide to sub-contract part of the work to other companies, for example sending velvet clothing to a specialist velvet cleaning service that employs gnomes to pick out the dirt from the fabric. This use of other services makes our laundry a composite service, because it is built out of other services. The client of the laundry service is unable to tell that the service provider uses other services, hence there is no difference between composite services and atomic services. Often BPEL will be used to create composite services from existing services.
Virtualising the Service InterfaceWe may want to change our laundry provider, and as long as they provide the same service we don't really care who does it. We may change the provider based on cost, or service level. In any case we don't want to have to change the way we work with the laundry service just because it is a different provider. Many companies provide their employees with a laundry drop off service. The employee (client of the service) does not care who actually provides the service, he just drops off his dirty washing at the drop-off point and picks up the clean washing later. This virtualisation of the location of the service makes it easy for the service provider to be swapped out without changing the clients using the service.
In the SOA world we may use an ESB to virtualise the endpoint by providing a fixed address for the service. In addition to providing a fixed address we may also compensate for slight differences in the interface by using a mediator to map between the format the client wants to use and the format the new laundry service uses.
Personalising the ServiceIf we are a regular customer then the laundry may decide to offer us better rates or some other additional service. This type of customisation may need to be accessed from several different places, for example the laundry may automatically iron shirts for premium customers, this impacts both the process of processing the laundry (the process flow) and also the billing engine, which should not charge for certain services based on the value of the customer. Within a service oriented architecture a rules service will enable us to centralise common business rules, such as the free ironing service. Centralising business rules in a rules service allows them to be applied consistently across an organisation, and managed in a single location, making changing them much easier. In the SOA world a rules engine can provide this.
Finding a LaundryWhere to find a good laundry. One option is to look in yellow pages for a laundry convenient to yourself. The equivalent in the SOA world is to look it up in a service registry.
Protecting Your SmallsAn obvious concern is that you don't want your personal clothing stolen on the way to the laundry or tampered with in any way. You expect the transport mechanisms and the procedures at the laundry to be such that your privacy will be protected and your smalls kept private. You don't view this as part of the service interface but as a more fundamental attribute of the service.
In the SOA world we can use declarative security to confirm who is sending the message, and also to encrypt all or part of the message to prevent tampering with it. Within the Oracle stack this functionality can be provided by the Web Services Manager.
A Clean SolutionI hope the suggestions above show why I like the laundry model and why I feel it relates better to SOA than does the lego model. If you have other suggestions for extending the model please let me know. Similarly if you have better models then let me know as well.
In the meantime may your whites stay clean and starched.
Pairing Off in XSLT
Pairing Off in XSLT
The SourceThe source XML looked like this
<?xml version="1.0" encoding="UTF-8" ?>
<exampleElement>
<AttributeElement>
<DisplayElement>
<SelectElement attribute1="A"/>
</DisplayElement>
</AttributeElement>
<AttributeElement>
<DisplayElement>
<PasswordElement attribute1="1"/>
</DisplayElement>
</AttributeElement>
...
<AttributeElement>
<DisplayElement>
<SelectElement attribute1="E"/>
</DisplayElement>
</AttributeElement>
<AttributeElement>
<DisplayElement>
<PasswordElement attribute1="5"/>
</DisplayElement>
</AttributeElement>
</exampleElement>
Note the pairing of the Attribute elements.
The TargetThe target XML looked like this
<?xml version = '1.0' encoding = 'UTF-8'?>
<exampleElement>
<Attribute>
<Select attribute1="A"/>
<Password attribute1="1"/>
</Attribute>
...
<Attribute>
<Select attribute1="E"/>
<Password attribute1="5"/>
</Attribute>
</exampleElement>
The ProblemThe challenge was after identifying a path with a SelectElement element how to select the following path that had a PasswordElement element.
The Answer is AxisThe trouble with XSLT is that I don't do enough of it to remember all the tools available. In this case it was very simple once I had remembered how axis work. Here is my solution
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<exampleElement>
<xsl:for-each select="/exampleElement/AttributeElement/DisplayElement/SelectElement">
<Attribute>
<Select>
<xsl:attribute name="attribute1"><xsl:value-of select="@attribute1"/></xsl:attribute>
</Select>
<Password>
<xsl:attribute name="attribute1">
<xsl:value-of select="following::AttributeElement[1]/DisplayElement/PasswordElement/@attribute1"/>
</xsl:attribute>
</Password>
</Attribute>
</xsl:for-each>
</exampleElement>
</xsl:template>
</xsl:stylesheet>
This solution iterates over all the SelectElement elements and then for each of those elements it picks out the following PasswordElement in the document. It does this by using the XPath expression "following::AttributeElement[1]/DisplayElement/PasswordElement/@attribute1".
The "following::" axis selects all nodes in the document that come after the given SelectElement element. This flattens the hierarchy enabling us to choose the next AttributeElement element by selecting the AtrributeElement element with index 1 (AttributeElement[1]). We can then traverse that part of the XML using the normal child axis. Simple when its done but when you rarely use axis other than the child axis it takes a while to remember how they work.
ReferenceI find the two O'Reilly books on XSLT to be very helpful when struggling with XPath and XSLT. These are the Doug Tidwell XSLT book and the Sal Mangano XSLT Cookbook.
I hope this saves sombody some time.



