Sunday, January 17, 2010

EJB 3.1 (Asynchronous Beans)

Enterprise Java Beans specifications have finally matured to a point where it may actually help with performance: container-managed Asynchronous beans.
speed
You can now specify a Session Bean (and/or a method) to be asynchronous. End-user perceived wait times can be significantly reduced with an asynchronous programming model that doesn’t force the complexity of AJAX, MoM or application-managed server threads.
With EJB 3.1 when you call the method from your client, the container will take the request and return immediately. Then it will dispatch the request to a bean instance within the pool of SLSBs.
The return type for async methods is either void or Future. The Future interface provides methods to check whether the operation has completed, gets the result – with options for a timeout and also cancel the operation. A concrete implementation of Future is AsyncResult which is available in the javax.ejb package.
Stateless EJBs may choose to return the AsyncResult object with any type returned. Transaction propagation is simple &  limited - REQUIRED=REQUIRES_NEW attributes. If your client is already in a transaction, or your beans are in a transaction, the async method is called in a totally new transaction with no propagation (as in synchronous methods). This makes a lot of sense, because the entire purpose of asynchronous calls are to decouple a process orchestration to speed up things. However, it does complicate compensation and atomicity. Software architects need to trade-off between transaction demarcation and generally ACID properties across various calls. Any application exception that gets thrown by the bean for a void return type cannot be handled by the client. If your bean can encounter an exception and your client cares about handling it, then return a Future<V> form the bean. The client must handle the exception on a Future.get and getCause from ExecutionException.
An entire bean (itself or via it’s super class) can be marked as @Asynchronous. Sometimes it makes sense to expose the same business function as a synchronous and an asynchronous interface, using the @Asynchronous tag can provide the cohesion with a decoupled interaction model. This opens the door to multiple use-cases that need a simple way to conduct asynchronous calls without the complexity of MDBs or managing application owned threads. EJB 3.1 has built upon the POJO model for EJBs with an excellent way to realize asynchronous server-side models.

Saturday, January 2, 2010

Google Chrome @ 5% (almost)

Google Chrome is now the 3rd most popular browser in the world.

According to recent reports here and here, Google's Chrome has overtaken Apple's Safari in the browser wars. While still at less than 5% chrome is no match for Microsoft's Internet Explorer which is slightly above 62%. Chrome is gaining strength quickly mostly due to two quality attributes: speed and reliability. Chrome is noticeably faster than Opera, IE, Firefox and Safari. It's reliability is unsurpassed due to its multi-process architecture.


Coming in at #3 just months after it's GA release is commendable. With new features like bookmark sync and support for themes and plug-ins it will rival the # 2 spot in a couple years, eating away Microsoft's and Mozilla's share.