EJB performances

Explain how to avoid large data transfer using EJBs.

- Avoid using entity beans to access the large data.

- Use session to contain complex interactions and reduce calls using RMI.

- Avoid the transaction that may span across multiple instances of the server.

- Address translation policies can be avoided using DNS names.

- Direct interaction with entities should be avoided.

What is lazy loading?

- Lazy loading is also known as dynamic function loading.

- Lazy loading allows a developer the specifications for components, which a program should not load directly into the storage by default at the program is started.

- Lazy loading can be used to improve the performance of the program in such case that, when the most of the dependent components are not actually used.

Explain how to lazy-load enterprise beans.

- Lazy loading for the creation of mdb with oracle-specific deployment descriptor which causes the lazy loading of the bean.

- Specify <min-instances> value to 0 and <listener-threads> value to 1.

- Subsequent to this configuration, the methods – createejb() and setContetxt(pContext) are called for the first time at time of retrieving a message by the bean.

- CMP engines also already supports lazy loading.

- By using fetch strategies using annotations in Jboss like:
@ManyToOne(fetch = FetchType.LAZY)

Discuss the advantages of smart stubs and show how to accelerate marshalling.

Advantages of smart stubs:

- A processing device is in a position to provide a service to other processing devices by replicating RMI or EJB objects, to make the architecture scalable and fault tolerable.

- Even though the failure of a communication medium may occur, the architecture will not render inoperable or degraded.

- A smart stud is able to find out the service providers and switch between them according to the balancing the load.

Accelerating Marshalling:

- The process of converting the data or objects into bytes is called marshalling.

- Marshalling technique is used to transfer data between RMI objects.

- Marshalling is an RMI concept of passing arguments from the client to server or returning values from server to client.

- The EJB stub is returned to the client.

- The marshalling is done by stubs and skeletons.

The acceleration process:

1. The stub and skeleton adapters adapt the clients to server’s objects

2. A serializable object is transmitted to the server by using the input parameters, if it uses IRemoteInterface.

3. An object that can be serializable will be sent to the client through a return value of a method of IremoteObjectInterface.

4. If at all a method that is run by the client on the remote object is actually run on the server.

5. If a method that is a part of serialization, makes the object of non-UnicastRemoteObject set to the client runs on the client.

6. For the RMIRegistry a class server must be running to load the stubs initially for the preparation for transmitting them to the clients.

Explain how to tune the performance when deploying EJBs.

- Make all the remote method calls into a single call and transfer the data needed by one transfer.

- By reducing the number of JNDI lookups.

- Use a mechanism / technique to return multiple data rows from a single entity bean instead of returning one row at a time.

- For any database batch of operation, it is suggested to use session beans.

- Use container-managed persistence (CMP) rather than bean-managed persistence (BMP).

- Implement the lowest transaction level which is consistent while maintaining the data coherency.

Explain how to improve the performance of EJB applications.

- By changing the default time out for transaction configuration time out which will effect the EJB transactions. This time out is specified to rollback or commit the transaction.

- For CMP, some of the parameters configuration are:

call-timeout : applies for entity and sessionbeans. Set the exact time for the specific beans.

do-select-before-insert : set to false, default value is true.

exclusive-write-access : force it to false, if locking is optimistic and not used for clustering.

validity-timeout : is used when exclusive-write-access=true and locking- mode=read-only.

For BMP:

locking-mode : must be optimistic for BMP.

max-tx-retries : Recommended value is 0, default value is 3.

For Session beans:

cache-timeout : applies for stateless session beans,default value is 60 seconds. If it is zero or negative, the cache-timeout is disabled.

Timeout : applies for stateful session beans, default is 30 seconds.
EJB containers
EJB containers - What is EJB container?, Explain the four types of container that J2EE supports, Developer classes vs. container classes, Explain the difference between servers and containers.
Explain EJB in brief.
EJB is a standard for developing server side in JAVA. It specifies agreement between components and application..
EJB Kinds - What are the kinds of EJB's?
EJB Kinds - There are 3 kinds of EJB's - Session beans, Entity Beans, Message-driven beans..
Post your comment