EJB

To improve performance, you might choose a stateless session bean if it has any of these traits.

  • The bean’s state has no data for a specific client.
  • In a single method invocation, the bean performs a generic task for all clients. 
  • The bean implements a web service.

Singleton session beans are appropriate in the following circumstances.

  • State needs to be shared across the application.
  • A single enterprise bean needs to be accessed by multiple threads concurrently.
  • The application needs an enterprise bean to perform tasks upon application startup and
    shutdown.
  • The bean implements a web service.

A message-driven bean is an enterprise bean that allows Java EE applications to process
messages asynchronously.

 

When a message arrives, the container calls the message-driven bean’s onMessage method to
process the message. The onMessage method normally casts the message to one of the five JMS
message types and handles it in accordance with the application’s business logic. The onMessage
method can call helper methods or can invoke a session bean to process the information in the
message or to store it in a database.

  

A message can be delivered to a message-driven bean within a transaction context, so all
operations within the onMessage method are part of a single transaction. If message processing
is rolled back, the message will be redelivered. For more information.

 

Session beans allow you to send JMS messages and to receive them synchronously but not
asynchronously.  To receive messages asynchronously, use a message-driven bean.

 

 

你可能感兴趣的:(Web,bean,ejb,jms,performance)