将 @Stateful 注入 MDB 是否合法?
将 @Stateful 注入 MDB 是否合法?
@Stateful
public class InteruptBean implements Interrupt {
....
}
@MessageDriven(...)
public class EchoTrigger implements MessageListener {
@EJB Interrupt interrupt;
....
}
或者更好的措辞:我可以使用有状态 EJB 在异步事件驱动架构中传递状态吗?
Is it legal to inject a @Stateful into an MDB?
@Stateful
public class InteruptBean implements Interrupt {
....
}
@MessageDriven(...)
public class EchoTrigger implements MessageListener {
@EJB Interrupt interrupt;
....
}
Or better phrased: Can I use a stateful EJB to pass state around in an asynchronous Event Driven Architecture?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这没有意义。因为有状态会话 Bean 旨在处理来自同一客户端的多个请求,以便它们具有面向客户端操作的处理。在这种情况下,MDB 将是 beans 客户端。 MDB 支持单一请求模型。请求到达 MDB(以消息的形式)并被处理。因此两种类型的 Bean 在处理模型上并不匹配。
Yes it does not make sense. Because stateful session beans are meant for processing multiple requests from same client so that they have client-actions oriented processing. In this case MDB will be beans clients. MDB supports single request model. A request comes to MDB (in form of message) and it is processed. So both types of beans don't match in processing model.
是的,这是“合法的”,但这是荒谬的。 MDB 实例像 SLSB 一样进行池化。 SFSB 超时后,MDB 将无法运行。
在某个时刻显式创建 SFSB,然后在发送的消息中传递对 SFSB 的引用以驱动 MDB 可能会起作用。
Yes, it's "legal", but it's nonsensical. MDBs instances are pooled like SLSBs. The MDB will become non-functional after the SFSB times out.
It might work to explicitly create the SFSB at some point, and then pass a reference to the SFSB in the messages being sent to drive the MDB.