Wednesday, December 06, 2006

Messaging Quickstart: Sample Code

The previous post described how to setup a Queue in Weblogic Server. This post shows the code necessary to run a Simple Messaging example using a servlet and Message Driven Bean. You can always implement an message listener instead of using a Message Driven Bean, but using MDBs is much cleaner and easier. Follow these steps to run the example

In Eclipse->Window->preferences, select xdoclet and set the Xdoclet home to the appropriate directory.

Create the Message Driven Bean

Create an EJB project in Eclipse.

In the J2EE perspective, right-click on the Deployment descriptor and create a new Message Driven Bean. Eclipse generates the required classes and the ejb-jar.xml file with the new MDB definition in it. Modify the Bean to look like this

Kudos to Abhi. Thanks for simplifying simple things.This is an exellent article. People tried reading the weblogic article 100 times and they don't get how to create a simple Queue and QueueConenction factory and MDB. Though I created in activeMQ and others easily, this weblogic JMS Queue's documentation especially for JMS on BEA server is confusing enough for any level of professional. Suggestion to Bea(oh, now it is Oracle right), to incorporate this link in their documentation.