Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MDB for a topic and the deployment descriptor

 
Neha Mohit
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>

__________________________________________________________________________
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic