![]() |
Messaging is evolving to support message-driven beans, as defined within the EJB 2.0 specification. Therefore, you are recommended to develop beans that handle messages in keeping with the latest draft EJB 2.0 specification.
A JMS listener invokes an instance of the stateless session bean defined for the destination in the configuration file. This bean must have an onMessage() method, which should conform to the following rules:
javax.jms.Message
.public void onMessage(javax.jms.Message msg) { try { System.out.println("MySessBean.onMessage(), msg text: "+((TextMessage)msg).getText()); } catch (Exception err) { err.printStackTrace(); } }
Code
example: The onMessage() method of a message bean. This figure shows a code extract for a basic onMessage() method
of a message bean. The method extracts the text from an incoming message and
sends that text to System.out.
You should also consider the function provided in the ejbCreate() and ejbRemove() methods, for which you are recommended to follow the Message DrivenBeans requirements:
Related tasks... | |
Developing a message bean to use extended messaging | |
Configuring the extended messaging service | |
Related concepts... | |
Parent: An overview of the extended messaging service | |