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.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值