• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

MDB for a topic and the deployment descriptor

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>

__________________________________________________________________________
 
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic