Managing Concurrent Requests with EJB Containers

Managing Concurrent Requests with EJB Containers

As you probably know, an important solution offered by EJB containers is the ability to manage concurrent requests and satisfy multiple clients while avoiding unpleasant issues. When the number of requests is too large and the available memory is insufficient, EJB containers try to use the hard disk to store the conversational state of each request that can’t be stored in memory. To accomplish this, the EJB container serializes the conversational state and stores it on the hard disk (known as the passivate process), and at the right moment it deserializes (restores) the conversational state and responds to the request (known as the activate process).

The limitation of this approach is that the container can’t serialize complex objects, such as sockets, database connections, JMS connections, and so on, because it can’t “capture” the state of such conversational states. This is why the EJB 3 provides the PrePassivate and PostActivate methods, annotated with @PrePassivate and @PostActivate, respectively. The first one, @PrePassivate, is called before storing the conversational state, which enables the developer to close any sockets and/or connections to databases and so on.

//called before storing conversational [email protected] public void passivate(InvocationContext ic){   //close any socket, database connection etc.}

When the conversational state needs to be restored from hard disk, the @PostActivate method is called after the bean is restored (activated) to allow the developer to restore the potential connections, sockets and so on.

//called after the conversational state is restored (activated)@PostActivatepublic void activate(InvocationContext ic){   //reopen any socket, database connection etc.}
Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved