Is it legal to introduce @Stateful in MDB?

Is @Stateful allowed in MDB?

@Stateful public class InteruptBean implements Interrupt { .... } @MessageDriven(...) public class EchoTrigger implements MessageListener { @EJB Interrupt interrupt; .... } 

Or is it better to state: can I use stateful EJB to transfer state in asynchronous Event Driven Architecture?

+4
source share
2 answers

Yes, it is "legal", but it is pointless. MDB instances are combined as SLSBs. MDB will stop functioning after SFSB failure.

You may need to explicitly create an SFSB at some point, and then transfer the link to the SFSB in messages sent to the MDB.

+2
source

Yes, that doesn't make sense. Because a beans state session is designed to handle multiple requests from a single client, so they have client-oriented processing. In this case, the MDB will be beans clients. MDB supports a single query model. The request arrives at the MDB (in the form of a message) and is processed. Thus, both types of beans do not match in the processing model.

+4
source

All Articles