EAI – Enterprise Application Integration

EAI enables companies to integrate transaction-driven architecture inside their middleware.

Using standards such as EDI (Electronic Data Interchange), Web Service Standards for synchronous and asynchronous messaging, fault handling, etc. Service Bus for transformation and virtualisation will provide integration hooks for as well legacy applications as existing applications.

They can interchange data and messages using an Enterprise Information Model in which the different data structures are defined using one common language.

Using adapter software, JCA (Java Connector Architecture), will allow you to integrate different applications in a technology agnostic manner. Using these adapters will then allow you to interchange data and messages without knowing the details of the underlying architecture of the legacy or existing applications.

In other words EAI will offer you a standards based transaction-driven approach to interconnect your diverse applications making use of 1 single source of thruth/failure.

The marriage of Toplink and Coherence

When we talk about Object Relational Mapping Frameworks or ORM frameworks we’re talking about mapping relational data to an object-oriented programming language.

The ORM framework will hold features such as support for JPA (Java Persistency API); database access control mechanisms such as JNDI, JTA, JDBC; distributed processes, 2 phase commit, etc.

So on the hand you need to be able to map your relational data to object relational data and on the other hand you need to have a clear view on your persistency layer.
How are you going to manage the different transactions in your application, how are you going to deal with distributed transactions, etc.

In Oracle Toplink 11g or the Oracle Toplink Grid you have the marriage of the ORM Framework and Coherence which offers you the power to control your transaction based application.

In other words you can hand over the persistency management to coherence instead of giving your architect and developers the burden of solving this puzzle themselves.

When using Toplink Grid you can choose to have Coherence manage the persisting of new and modified Entities. This integrated solution involves a layer between JPA and the data store where the grid can be leveraged to scaling beyond the database bound operations.

In other words you’re application doesn’t need to wait for your database transaction to return an answer before it can proceed. Using asynchronous processing in your application will be a huge improvement for the end users’ experience and will leave the responsability to the JPA layer were it needs to reside.

For more information regarding the Toplink Grid, read the following article.

This is a whole new way of thinking about persistency and data centric web applications which will have a great influence on as well the software architects as the end users’ experience.

Will we still have the so called ‘slow java web apps’ versus ‘data centric web apps’ which can lead to huge discussions amongst ‘client-server developers’ and ‘web developers’ ?

ApEx 3.2 : Page Security -> Autocomplete

A nice enhancement in the new ApEx version 3.2 is that you can set autocomplete off under page security. AutoComplete in HTML forms stores information entered into INPUT_text, the next time that a user visits your Web page a list of previously used data will appear.

Go to Edit Page -> Page Attributes -> Security and you will see the new option Form Auto Complete.

The default value when creating a page is “On”, setting it to “Off” will generate autocomplete=”off” in your page FORM tag, now a user will not see a list of previously entered data anymore.

ApEx 3.2 : Session Timeout

If you are planning to play the new Oracle APEX 3.2 version then be sure to checkout the new security feature Session Timeout.

Session Timeout will automatically invalidate your apex session if you use it. You can find session timeout under Shared Components -> Edit Security Attributes where you have have 2 options:

- Maximum Session Length: setting this property will allow you to define how long a user can use his session when logging in into your application, after witch the user will be forced to login again.

- Maximum Session Idle Time: Setting this property will define how many seconds a user can be idle before his/her session will be invalidated and the user will be forced to login again.

Optionally you can set a logout URL where you will redirect the user to, if the URL is an ApEx page then remeber to redirect the user to a public page.

The documentation of this new feature says that you can use three substitution items for your url: &APP_SESSION., &SESSION., and &APP_ID., although the session substitution items would probably have little value seeing the session has ended.

ODTUG Kaleidoscope 2009 – Must attend event of the year!

The previous year we went to ODTUG to talk about our quality assurance toolkit developed for ApEx. This year we’re going to talk about data integration services delivered using OBI EE, ODI and of course Oracle Warehouse Builder.

And I’m also very pleased to announce the ‘ADF Methodology for the Masses’ community will also present during this developers’ event.
During the sundown session of the ACE’s you will become more familiar with the program and of course we will try and provide the necessary take aways for everyone interested in ADF Development. If you’re interested in what we’ve achieved so far and would like to join our community to exchange experience and knowledge: the Oracle wiki page, the google group.

More than 150 technical sessions, more than 30 hands-on sessions and of course the chance to meet the community and exchange knowledge and experience … the ROI for any developer using Oracle technology is delivered during this conference.

So don’t hesitate, let’s register for ODTUG Kaleidoscope 2009 !

We’re attending, that’s for sure ;o)

Oracle 4 Newbies: thé Powerday

After our ‘Oracle for Newbies’ seminar, we invited all attendees for a Powerday. The participants would get the opportunity to try out everything we had shown in the seminar. Last Monday we started our Powerday with 11 curious attendees.

The ‘half a day’ – Powerday consisted of 3 parts: 1) the installation of Oracle Express Edition and an upgrade to the last Oracle Application Express version, 2) building a wizard driven application and 3) building and modifying manually some apex functionality.

For the installation part, we asked every attendee to bring his own portable. We planned to have the software successfully installed on every pc in one hour. And yes, they all did it. After 1 hour and 10 minutes, everybody had an Oracle database with Apex 3.1 up and running!

For the second part, we gave a demo on how to create a wizard-based application. Now it was up to them! We provided some excel sheets with the data. Starting from these excel sheets, thanks to the ease of Oracle Application Express, they managed to create the Oracle data model, fill the tables with the excel data and create a web application to do all possible data manipulation. And again… One hour later, they all had their first own Apex application up and running.

In the last part of our Powerday, we did some more advanced and ‘not so wizard-driven’ stuff like modifying or adding some functionality in the application, implementing blob functionality (upload and download of images), implementing security (authorization) and lots of other nice things. Not only ‘we’ did all this, at the end of the day, they all had these features implemented in their application.

All participants were enthusiast, and hopefully we convinced them to start using Oracle and Apex.

Oracle BI & BPM

When you talk about Business Intelligence, the true added value lies in real-time reporting. The dashboards or reports presented to you need to present accurate information about e.g. stock, human resources, bench marking, etc. This real-time reporting could be augmented even more when you can take action straight away when benchmarks aren’t met, campaigns need to be organised etc. In other words tighter integration with your reporting environment to make your company more agile and lean.

So let’s have a look at both technologies briefly:

  1. BPM = Business Process Management
  2. BPM gives you the opportunity to manage the existing business processes End 2 End. In other words you will define a portfolio of all existing business processes, analyse these business processes using the standards based language BPMN (Business Process Modelling Notation), simulate these processes to check if KPI’s are met, if needed re-engineer them, to finally start automating and executing these business processes using the standards based language BPEL (Business Process Execution Language).

  3. BI = Business Intelligence
  4. BI gives you the ability to gather and provide access to real-time information. It can deliver dynamically generated content, provide insight regarding benchmarks, forecasting and actionable tasks and most important of all guide users towards insight and action. The focus of BI is moving towards insight-driven business processes, to give users the ability to optimize these processes on unified, real-time and predictive data.

So how can we make this happen, how can we provide insight-driven business processes without loosing the focus on the data?

Some of the functionalities we can perform with the Oracle BIEE Web Services:

  1. Extract results from BI and feed them to external applications
  2. Execute queries and retrieve results.
  3. Execute iBots (BI Alerts).

By invoking these web services from within bpel processes we can interact with in flight business data and react when needed.

For more information regarding this integration and interaction, have a look at Oracle BI Webservices & BPEL.

Hibernate Transaction Choices

I take part in a project using Spring MVC and Hibernate technologies. During this project, we had to make some transaction choices. The transaction management could be handled by the HibernateTransactionManager. With the use of annotations, the manager could recognize what kind of transaction should be opened.

A transaction could run in different kind of modes. The default flushing mode is auto. In this case the database session is sometimes flushed before query execution in order to ensure that queries never return stale state. The side effect of unexpected flushes caused us some problems in the execution of DML statements within business logic methods.

What if you have to update some relevant objects before the edited object may be saved to the database? Or you want to do some validation on the unsaved object and you need other persistent objects to do this validation. We consider an object being persistent when the state of the object is the same as its state in the database.

On most forums, hibernate users propose to override the auto flush mode by the manual flush mode to prevent unwanted flushes. A database session in manual flushmode is only flushed when Session.flush() is explicitly called by the application. My team members and I do not favor this kind of solution. It’s like overruling the normal transaction behavior.

We prefer to split up the transaction methods. Like I said in Spring MVC it is possible to indicate which kind of transaction should be opened by the HibernateTransationManager. This is done with annotations set in classes and class methods. If the method only retrieves data from the database, the transaction should not be flushed and will be a read-only method.

We did some trials on our application. Within our model, managers are containing business logic interacting with the Dao’s setting up statements to save and retrieve data information. An important decision is at which level a new transaction should be created. As the Dao’s setting up statements, it might be a good solution to open and close transactions as Dao methods are called.

For example:
We try to update the salary of an employee in a company. When the employee’s salary is more than his superior, the superior’s salary is increased with the same value.

public EmployeeManager{
private EmployeeDAO employeeDAO;

public Employee update(EmployeeDto employeeDto){

// retrieve the object as currently known in the DB
Employee employee = employeeDAO.getById(employeeDto.getId());
Employee superior = employee.getSuperior();

// compare the salary update
if(employeeDto.getSalary() > superior.getSalary()){
int difference = employeeDto.getSalary() -employee.getSalary();

// increase the superior’s salary and update
superior.setSalary(superior.getSalary() + difference);
employeeDAO.update(superior);
}

// update the employee
return employeeDAO.merge(employeeDto);
}
}

The business logic to update the employee’s salary is maintained by an EmployeeManager.
As entities need to be saved, updated or deleted, this is done through different Dao methods.
In this case three transactions are created.

1) employeeDAO.getById(employeeDto.getId()) – type: read-only
2) employeeDAO.update(superior) – type: normal (auto flush)
3) employeeDAO.merge(employeeDto) – type: normal (auto flush)

What if something went wrong in the last transaction method? Only the last transaction will be rolled back. The superior’s salary could be increased when the employee’s salary is still the same. If the user retries to increase the employee’s salary, the superior’s salary will receive twice the wage storage.

For information:
At the end of the transaction, a merge is done instead of an update to prevent a Hibernate TransientObjectException. The transient object – employeeDto – could not be updated when it is not yet persistent with the database. With the use of merge; the changes between the transient and the persistent object are merged to the database.

It’s clear this is not the right transaction choice. We moved the transaction management to the manager level. A better choice, cause now the whole manager method will end in one transaction and also the child methods executed within take over the same transaction.

Another example:
The wage storage rules remain but the superior will be updated by cascade. This means no update action should be called, the update is done automatically with the merge of the employee.

We also update the last name of the employee and check if the name is not already used by another employee.

public EmployeeManager {
private EmployeeDAO employeeDAO;

public Employee update(EmployeeDto employeeDto) throws EmployeeException {

// retrieve the object as currently known in the DB
Employee employee = employeeDAO.getById(employeeDto.getId());
Employee superior = employee.getSuperior();

// compare the salary update
if(employeeDto.getSalary() > superior.getSalary()){
int difference = employeeDto.getSalary() -employee.getSalary();

// increase the superior’s salary and update
superior.setSalary(superior.getSalary() + difference);
}

if(!employeeDto.getLastName().equals(employee.getLastName()) &&
lastNameIsUsedByOtherEmployees(employeeDto.getLastName()){
throw new EmployeeException(“Last name is already used by another employee”);
}

// update the employee
return employeeDAO.merge(employeeDto);
}

private Boolean lastNameIsUsedByOtherEmployees(String lastName){
List employees = employeeDAO.getEmployeesByLastName(lastName);

if(employees.size() > 0){
return true;
}

return false;
}
}

The whole method results in one transaction. Data is read from the database and at the end of the method the employee is updated. Propose the new salary of the employee is higher than his superior and also the person’s name is changed. While the persistent superior object is changed, employees are fetched from the database via the employee’s last name validation. That moment the object state is synchronized with the database and the superior is updated directly before the employee might have been updated. This is caused by the auto flush mode the transaction is running on.

The transaction is flushed whenever changes to a persistent object are made. As soon as a new read is done, Hibernate updates the object state of the employee object. We didn’t aim to flush (commit) at this point of our transaction. We still have to do validation and maybe an exception will to be thrown.

Another solution is to split manager methods into read-only and not read-only transactions. Validation of objects is done with read-only methods and the real database changes are done in another method.

This could look like this:

public class EmployeeManager{
private EmployeeDAO employeeDAO;

public void validate (EmployeeDto employeeDto) throws EmployeeException {

// retrieve the object as currently known in the DB
Employee employee = employeeDAO.getById(employeeDto.getId());

if(!employeeDto.getLastName().equals(employee.getLastName()) &&
lastNameIsUsedByOtherEmployees(employeeDto.getLastName()){
throw new EmployeeException(“Last name is already used by another employee”);
}

return employee;
}

public Employee update(EmployeeDto employeeDto) {
// retrieve the object as currently known in the DB
Employee employee = employeeDAO.getById(employeeDto.getId());
Employee superior = employee.getSuperior();

// compare the salary update
if(employeeDto.getSalary() > superior.getSalary()){
int difference = employeeDto.getSalary() -employee.getSalary();

// increase the superior’s salary and update
superior.setSalary(superior.getSalary() + difference);
}

// update the employee
return employeeDAO.merge(employeeDto);
}
}

public class EmployeeController {
private EmployeeManager employeeManager;

public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors){
EmployeeDto employeeDto = (EmployeeDto) command;

try {
employeeManager.validate (employeeDto);
employeeManager.update(employeeDto);

} catch (EmployeeException e){
errors.rejectValue(“lastName”,”lastName.alreadyUsed”);
return showForm(request, errors, this.getFormView());
}

return new ModelAndView(……);
}

}

The EmployeeController implements two method calls to the manager. The first method is used for validation and second for updating the database.

Do you have other experiences in taking Hibernate transaction choices or do you know a better solution to solve this issue? Please let me know…