Creating a Message-Driven Bean
The setMessageDrivenContext() method can throw EJBException if there is a container or system level error of some kind. See the section called “Handling Exceptions” for more details. What follows is an example setMessageDrivenContext() method that saves its EJBContext and JNDI context:
private MessageDrivenContext mdbContext; private Context jndiContext; public void setMessageDrivenContext (MessageDrivenContext ctx) { mdbContext = ctx; try { jndiContext = new InitialContext(); } catch (NamingException nameEx) { throw new EJBException(nameEx); } }
After calling setMessageDrivenContext(), the container calls the bean's ejbCreate() method, which takes no parameters. You could use this method to allocate resources, ...
Get Sams Teach Yourself J2EE™ in 21 Days now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.