Add other JMS subscriber in topic
By pblaha on Nov 28, 2005
On of the big advance of the topic is that other subscriber can be added very easy. For instance, we have existing order application that have one ProcessOrder subscriber and we would like to add other one. In this post I will show how you can add new subscriber in NetBeans 5.0, which changes should be done:
- First, we create new EJB module with name Accounting. We would like to add new module that will make some order's accounting tasks
- Add new MDB bean in this project. Since, we are using durable subscription, new MDB should have different clientId name in ejb-jar.xml than other one. The clientid should be unique.
- Under Server resources node you can see new JMS Resources. However, we would like to use existing from Order module. Delete these resources.
- We should change sun-ejb-jar.xml file as well. Open sun-ejb-jar.xml file and change these elements: jndi-name for mdb-connection-factory and message-destination-name. See code snapshot:
<ejb> <ejb-name>AccountBean</ejb-name> <jndi-name>jms/ProcessOrderBean</jndi-name> <mdb-connection-factory> <jndi-name>jms/ProcessOrderDestinationFactory</jndi-name> </mdb-connection-factory> </ejb> <message-destination> <message-destination-name>AccountDestination</message-destination-name> <jndi-name>jms/ProcessOrderBean</jndi-name> </message-destination>
- Add OrderLib project that includes Order TO on project's classpath.
- Implement onMessage method.
- Deploy and test JMS client. You should see that both EJB modules received order. Account module sources are avalaible here.