即使有池化,MDB 的寿命真的很短吗?
Are MDBs really short-lived even with pooling?
我有点惊讶地在 Oracle 文档中找到一行,说明 MDB 的寿命相对较短:
Message-driven beans have the following characteristics.
- They execute upon receipt of a single client message.
- They are invoked asynchronously.
- They are relatively short-lived.
- They do not represent directly shared data in the database, but they can access and update this data.
- They can be transaction-aware.
- They are stateless.
http://docs.oracle.com/javaee/6/tutorial/doc/gipko.html#gipmj
这真的意味着多边开发银行应该被汇集在一起吗?
construct/destruct 这些比无状态会话 bean 更频繁有什么具体原因吗?
可以配置消息驱动池。配置 MDB 池主要关注的是消息到达率。
MDB 与 Stateless 不同,从某种意义上说,它们旨在收听消息完成工作并返回休眠状态。另一方面,无状态位于业务层前面,监听来自 presentation/web 层的请求,这意味着用户负载很重。
Relatively short lived
我的猜测是每个 EJB 都与一个线程相关联,这意味着容器正在为其保留一些资源。当容器需要资源的时候,理论上选择的是砍MDB而不是Stateless。
[更新]
我必须纠正自己,如果您阅读了规范,即使对于会话对象 (Steteless/Stateful),也会报告相同的短语 Relatively short lived。虽然实体被详细描述为长期存在:
Can be long-lived (lives as long as the data in the database).
The entity and its primary key survive the crash of the EJB container.
If the state of an entity was being updated by a transaction at the
time the container crashed, the entity’s state is restored to the
state of the last committed transaction when the entity is next retrieved.
很明显,这些短语是用来比较实体对象和会话对象的。因此,重新假设:
- 一个会话对象。 (相对短暂)
- 一个消息驱动的对象。 (相对短暂)
- 实体对象。 (可以长寿)
我有点惊讶地在 Oracle 文档中找到一行,说明 MDB 的寿命相对较短:
Message-driven beans have the following characteristics.
- They execute upon receipt of a single client message.
- They are invoked asynchronously.
- They are relatively short-lived.
- They do not represent directly shared data in the database, but they can access and update this data.
- They can be transaction-aware.
- They are stateless.
http://docs.oracle.com/javaee/6/tutorial/doc/gipko.html#gipmj
这真的意味着多边开发银行应该被汇集在一起吗? construct/destruct 这些比无状态会话 bean 更频繁有什么具体原因吗?
可以配置消息驱动池。配置 MDB 池主要关注的是消息到达率。
MDB 与 Stateless 不同,从某种意义上说,它们旨在收听消息完成工作并返回休眠状态。另一方面,无状态位于业务层前面,监听来自 presentation/web 层的请求,这意味着用户负载很重。
Relatively short lived
我的猜测是每个 EJB 都与一个线程相关联,这意味着容器正在为其保留一些资源。当容器需要资源的时候,理论上选择的是砍MDB而不是Stateless。
[更新]
我必须纠正自己,如果您阅读了规范,即使对于会话对象 (Steteless/Stateful),也会报告相同的短语 Relatively short lived。虽然实体被详细描述为长期存在:
Can be long-lived (lives as long as the data in the database). The entity and its primary key survive the crash of the EJB container.
If the state of an entity was being updated by a transaction at the time the container crashed, the entity’s state is restored to the state of the last committed transaction when the entity is next retrieved.
很明显,这些短语是用来比较实体对象和会话对象的。因此,重新假设:
- 一个会话对象。 (相对短暂)
- 一个消息驱动的对象。 (相对短暂)
- 实体对象。 (可以长寿)