5 scenarios where you can bet for EJB3


I have most of the times worked on spring based projects. Recently I got a chance to design business layer based on EJB 3.

Below are the observations based on my experience.Any architect may consider EJB 3 , for these aspects.

  1. JMS Consumers: When you need to develop JMS consumers: EJB supported MDB are simplest JMS consumers having annotated transaction support.
  2. Asynchronous Communication: In EJB 3.1, session beans support asynchronous method invocations. Bean methods annotated with @Asynchronous are invoked asynchronously. When a client invokes methods with the @Asynchronous annotation, the container immediately returns control to the client and invokes the method in a different thread. The method may return a future object to allow the client to check on the status of the method invocation, and retrieve result values that are asynchronously produced. EJB 3.1 supports this feature by using Future, which is part of standard java concurrency. Future represents the result of an asynchronous computation. It supports both model of communication:,
    1. Retrieve-result-later asynchronous methods having Future<?> return type.
    2. Fire-and-forget asynchronous methods having void return type
  3. Multi node deployment
  4. Distributed Application: EJB3 support for remoting and simple distributed transaction support makes spring first choice for distributed applications.
  5. State-full Behavior

 

You can achieve all the features with other frameworks as well, but one need to develop custom components or integrate other frameworks, while these features are embedded in EJB 3 and can be applied easily.