将@Stateful注入MDB是否合法? [英] Is it legal to inject a @Stateful into an MDB?

查看:131
本文介绍了将@Stateful注入MDB是否合法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将@Stateful注入MDB是否合法?

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;

    ....
}

或更好的措辞:我可以使用有状态EJB在异步事件驱动架构中传递状态吗?

Or better phrased: Can I use a stateful EJB to pass state around in an asynchronous Event Driven Architecture?

推荐答案

是的,它是合法的,但是这是荒谬的。 MDB实例像SLSB一样汇集在一起​​。在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.

可能在某些时候显式创建SFSB,然后将引用传递给SFSB发送消息以驱动MDB。

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.

这篇关于将@Stateful注入MDB是否合法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆