File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes MDB for a topic and the deployment descriptor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "MDB for a topic and the deployment descriptor " Watch "MDB for a topic and the deployment descriptor " New topic
Author

MDB for a topic and the deployment descriptor

Neha Mohit
Ranch Hand

Joined: Apr 25, 2006
Posts: 87
Hi all,

I have a publisher class to publish a Topic. But is a little confused how to write the MDB for the subscriber ; besides what all entries are required in the deployment desciptor of the MDB.



Thanks in advance
Shailesh Kini
Ranch Hand

Joined: Oct 17, 2001
Posts: 153
Hi Neha,

It is not clear from your post regarding the application server you are using as the steps could vary a little for different servers.

There is a little administration part involved as well.

As far as writing an MDB is concerned it is fairly simple... Just create a class that implements javax.jms.MessageListener and provide the implementation for the onMessage(Message message) method.

If you are using JEE 5 then you have an option to use annotations. If not then here's a sample ejb-jar.xml

--------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee"
version = "3.0"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
<enterprise-beans>
<message-driven>
<ejb-name>TopicMDB</ejb-name>
<ejb-class>com.blah.core.blah.mdb.MDBClass</ejb-class>
<transaction-type>Container</transaction-type>
<message-destination-type>javax.jms.Topic</message-destination-type>
<message-destination-link>TopicNamehere</message-destination-link>
<resource-ref>
<description>
Topic Connection Factory where the message will be placed to be consumed
</description>
<res-ref-name>jms/URChoice</res-ref-name>
<res-type>javax.jms.TopicConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-env-ref>
<description>

</description>
<resource-env-ref-name>jms/TopicMDB</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Topic</resource-env-ref-type>
</resource-env-ref>
</message-driven>
</enterprise-beans>
</ejb-jar>

__________________________________________________________________________


Shailesh Kini.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MDB for a topic and the deployment descriptor