The latest AS 7.0.1 release made finally available the last EJB component which was missing: Message Driven Beans. Let's see how to develop a simple MDB on AS 7 with this 5 minute tutorial!
In the current AS 7 release, the messaging domain is included into the *-preview.xml configuration files. In the future 7.1 release, the messaging configuration will be merged in the main configuration file.
However that's not a big issue: for example if you want to run JMS applications on AS 7 standalone, you should start your server using the standalone-preview.xml configuration file.
In practice this just requires using the --server-config when starting your server. For example:
Ok, so we want to roll MDB. Here's a very simple one which does a simple job of printing the text message received:
This MDB consumes messages from the queue sampleQueue. In order to add this queue from the CLI just issue:
[standalone@localhost:9999 /] add-jms-queue --name=sampleQueue --entries=queue/sampleQueue
If you want to skip this step, you could just use the queue/test which is by default configured in the AS 7.
Ok. Now all you need is a JMS sender. To make things super fast just add a Servlet to your application:
By invoking your Servlet one JMS message will be sent to the defined queue, resulting in: