Enterprise JavaBeans 3

Stateless session beans (EJB 3)

As noted earlier, stateless session beans model tasks don’t maintain conversational state. This means that session beans model tasks can be completed in a single method call, such as placing a bid. However, this does not mean that all stateless session beans contain a single method, as is the case for the PlaceBid-Bean in topic […]

Stateful session beans (EJB 3)

Stateful session beans are guaranteed to maintain conversational state. They are not programmatically very different from their stateless cousins: as a matter of fact, the only real difference between stateless and stateful beans is how the container manages their lifecycle. Unlike with stateless beans, the container makes sure that subsequent method invocations by the same […]

Session bean clients (EJB 3)

A session bean works for a client and may either be invoked by local clients collocated in the same JVM or by a remote client outside the JVM. In this section we first discuss how a client accesses a session bean and then see how the @EJB annotation is used to inject session bean references. […]

Performance considerations for stateful beans (EJB 3)

Whether or not they deserve it, stateful session beans have received a bad rap as performance bottlenecks. There is truth behind this perception, quite possibly due to poor initial implementations for most popular application servers. In recent years, these problems have been greatly alleviated with effective under-the-hood optimizations as well as better JVM implementations. However, […]

Session bean best practices (EJB 3)

In this section we outline some of the best practices for session beans that you can use while building the business logic tier for your application. Choose your bean type carefully. Stateless session beans will be suitable most of the time. Carefully examine whether your application needs stateful session beans, because it comes with a […]

Messaging concepts (EJB 3)

When we talk about messaging in the Java EE context, what we really mean is the process of loosely coupled, asynchronous communication between system components. Most communication between components is synchronous, such as simple method invocation or Java RMI. In both cases, the invoker and the invocation target have to be present for the communication […]

Introducing Java Messaging Service (EJB 3)

In this section we provide an overview to JMS API by building a basic message producer. JMS is a deceptively simple and small API to a very powerful technology. The JMS API is to messaging what the Java Database Connectivity (JDBC) API is to database access. JMS provides a uniform, standard way of accessing MOM […]

Working with message-driven beans Part 1 (EJB 3)

We’ll now build on our brief coverage of MDBs in topics 1 and 2 and explore MDBs in detail, why you should consider using them, and how to develop them. We’ll also discuss some best practices as well as pitfalls to avoid when developing MDBs. Message-driven beans are EJB components designed to consume the asynchronous […]

Working with message-driven beans Part 2 (EJB 3)

SubscriptionDurability If our MDB is listening on a topic, we can specify whether the topic subscription is durable or nondurable. Recall that in the pub-sub domain, a message is distributed to all currently subscribed consumers. In general, this is much like a broadcast message in that anyone who is not connected to the topic at […]

MDB best practices (EJB 3)

Like all technologies, MDBs have some pitfalls to watch for and some best practices that you should keep in mind. This is particularly true in demanding environments where messaging is typically deployed. Choose your messaging models carefully. Before you wade knee deep in code, consider your choice of messaging model carefully. You might find that […]