Explain how to avoid large data transfer using EJBs.
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 configuratin, the mehtods – 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:
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:
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, which is the default value
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.
- Avoid using entity beans to access 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 configuratin, the mehtods – 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.
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:
- The stub and skeleton adapters adapt the clients to server’s objects
- A seriablizable object is transmitted to the server by using the input parameters, if it uses IRemoteInterface.
- An object that can be serializable will be sent to the client through a return value of a method of IremoteObjectInterface
- If at all a method that is run by the client on the remote object is actually run on the server.
- If a method that is a part of serialization, makes the object of non-UnicastRemoteObject set to the client runs on the client.
- For the RMIRegistry a class server must be running to load the stubs initially for the preparation for transmitting them to clients.
- Make all remote method calls into a single call and transfer the data needed by one transfer
- By reducing the no. 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 transactionlevel which is consistent while maintaining the data coherency.
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, which is the default value
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.