An MDB may decide to implement the MessageDrivenContext
interface. This interface is similar to the SessionContext
interface provided for session beans, and provides information about an MDBs environment. We use the @Resource
annotation to inject the context object into an MDB:
@Resource private MessageDrivenContext ctx;
There are a number of methods such as setRollbackOnly()
and getRollbackOnly()
which are identical to the corresponding SessionContext
methods. These are used in the context of transactions, which we discuss later in this chapter.
Remaining MessageDrivenContext
methods deal with Timer or Security aspects, which we cover in later chapters.