The objective is to learn how to develop a Message-Driven Bean (MDB).
Creation the jBoss PTP queue
Edit the file jbossmq-destinations-service.xml in $JBOSS/server/default/deploy/jms/
and add the following code:
<mbean code="org.jboss.mq.server.jmx.Queue"
name="jboss.mq.destination:service=Queue,name=JyperionLogQueue">
<depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
</mbean>
Save. That's all. jBoss will create the queue..
MDB: The code
A MDB is a simple Java class implementant les interfaces MessageDrivenBean, MessageListener.
The most important method is public void onMessage(Message message). This method will be called
by the container upon reception of a message.
MDB XDoclet tags
There are two tags to specify: @ejb.bean and the propriatary tag @jboss:destination-jndi-name:
/**
* LogMBean
*
* @ejb.bean
* name="LogMBean"
* acknowledge-mode="Auto-acknowledge"
* destination-type="javax.jms.Queue"
* subscription-durability="NonDurable"
* transaction-type="Container"
*
* @jboss:destination-jndi-name name="queue/JyperionLogQueue"
*
* @author janaudy
*/
public class LogMBean implements MessageDrivenBean, MessageListener { ...
... and that's all!
Instead of using a PTP queue, you will develop a Pub/Sub application, like a Trading System, where a Trader
registers an interest in a specific Topic.
You will have to configure jBoss to create a Pub/Sub Topic.