Java Reference
In-Depth Information
Before moving on, let's discuss the code that NetBeans generates in our Message
Driven Beans. Notice that the generated class is decorated with the @MessageDriven
annotation. This annotation marks our class as a Message Driven Enterprise
JavaBean.
The mappedName attribute of the @MessageDriven annotation should contain the
JNDI name of the JMS destination (queue or topic) that our message driven bean will
be assigned to.
The value of the activationConfig property must be an array of
@ActivationConfigProperty annotations. The @ActivationConfigProperty
annotation is used to specify values for certain properties. It has a propertyName
attribute used to specify the property name, and a propertyValue attribute used to
specify the property value.
When developing message driven beans, we use @ActivationConfigProperty
annotations to specify the acknowledge mode of the bean (see explanation in
the previous section), and the destination type of the JMS destination the bean is
assigned to, which can be javax.jms.Queue when using point to point messaging
domain, or javax.jms.Topic when using the publish/subscribe messaging domain.
In addition to the annotations, we should also notice that the generated message
driven bean implements javax.jms.MessageListener , which has a single method,
onMessage() . All message driven beans must implement this interface.
Summary
In this chapter we covered how to develop messaging applications using the JMS
API with NetBeans. We looked at how to configure the application server by adding
JMS resources directly from NetBeans. We also covered how NetBeans can generate
most of the code necessary to send a JMS message, leaving us application developers
to simply "ill in the blanks", and write only the business logic part that is specific to
our application. Similarly, we covered how NetBeans can generate most of the code
necessary to receive a JMS message from a Message Driven Bean, again leaving only
the business logic part of our application to be written by hand.
 
Search WWH ::




Custom Search