Java Reference
In-Depth Information
Level.SEVERE, null, ex);
Notice that we had to cast the message parameter to the actual sub-interface that was
sent to the message destination, which in our case is javax.jms.TextMessage . To
obtain the message contents, we invoked the getText() method of TextMessage .
This method throws JMSException ; because of this, we had to wrap its invocation in
a try / catch block.
NetBeans will remind us that we need to catch JMSException by
underlining the offending code with a wiggly red line. By hitting
Alt + Enter at the offending line we can have NetBeans generate the try /
catch block automatically.
At this point we are ready to try our application. We can do so by simply
right-clicking on our Enterprise Application Project and selecting Run . At this point
the application will be deployed, and the application client project will be executed,
sending a message to our message queue. Our EJBs will also be deployed, and the
application server will automatically assign one to process the message sent to the
queue. We can see the output of the message driven bean in the application
server log.
You might notice an exception in the screenshot above. This is due to a
known GlassFish issue and can safely be ignored.
As we can see, NetBeans automates most of the "grunt work" needed to write
applications taking advantage of the JMS API, leaving us to only write the business
logic part that is specific to our application.
Search WWH ::

Custom Search