MDB: Difference between revisions
(→Code) |
(→Code) |
||
Line 18: | Line 18: | ||
==Code== | ==Code== | ||
An MDB ''must'' implement the appropriate listener interface for the messaging type the MDB supports. If the MDB implements <tt>javax.jms.MessageListener</tt> interface, that distinguishes the MDB as a JMS MDB. Alternatively, the MDB must specify the message listener interface using the [ | An MDB ''must'' implement the appropriate listener interface for the messaging type the MDB supports. If the MDB implements <tt>javax.jms.MessageListener</tt> interface, that distinguishes the MDB as a JMS MDB. Alternatively, the MDB must specify the message listener interface using the [#The_.40MessageDriven_Annotation|@MessageDriven]] annotation or the <tt>[[#messaging-type|messaging-type]]</tt> deployment descriptor element. | ||
==Deployment Descriptor== | ==Deployment Descriptor== |
Revision as of 19:26, 17 March 2017
Internal
Overview
A Message-Driven Bean (MDB) is an asynchronous message consumer, invoked by the container as a result of the arrival of a message at the JMS destination serviced by the message-driven bean.
To a client, an MDB is a message consumer that implements some business logic running on the server. A client accesses an MDB by sending messages to the JMS destination associated with the MDB container of that type. MDBs are anonymous. They have no client-visible identity. MDB instances have no conversational state either, meaning they do not maintain state for a specific client. All bean instances are equivalent when they are not involved in servicing a client message. An MDB instance is created by the container to handle the processing of the messages for which the MDB is the consumer. Its lifetime is controlled by the container.
API
The @MessageDriven Annotation
An MDB must be annotated with the @MessageDriven annotation, or denoted in its deployment descriptor as a message driven bean.
Code
An MDB must implement the appropriate listener interface for the messaging type the MDB supports. If the MDB implements javax.jms.MessageListener interface, that distinguishes the MDB as a JMS MDB. Alternatively, the MDB must specify the message listener interface using the [#The_.40MessageDriven_Annotation|@MessageDriven]] annotation or the messaging-type deployment descriptor element.
Deployment Descriptor
messaging-type
Example
A working MDB example is available here