[jboss-cvs] JBoss Messaging SVN: r7093 - in trunk/examples/jms/management-notifications: server0 and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 28 08:32:08 EDT 2009


Author: jmesnil
Date: 2009-05-28 08:32:08 -0400 (Thu, 28 May 2009)
New Revision: 7093

Modified:
   trunk/examples/jms/management-notifications/readme.html
   trunk/examples/jms/management-notifications/server0/jbm-configuration.xml
   trunk/examples/jms/management-notifications/server0/jbm-jms.xml
   trunk/examples/jms/management-notifications/src/org/jboss/jms/example/ManagementNotificationExample.java
Log:
Management Notifications Example

* modified configuration + code to look up the notifications queue
  from JNDI instead of instantiating directly with JBossQueue

Modified: trunk/examples/jms/management-notifications/readme.html
===================================================================
--- trunk/examples/jms/management-notifications/readme.html	2009-05-28 12:31:04 UTC (rev 7092)
+++ trunk/examples/jms/management-notifications/readme.html	2009-05-28 12:32:08 UTC (rev 7093)
@@ -25,11 +25,18 @@
      <p>We will also create a queue corresponding to the example's address to hold notifications</p>
      <pre>
          <code>&lt;queues&gt;
-            &lt;queue name="example.notifications"&gt;
+            &lt;queue name="jms.queue.notificationsQueue"&gt;
                &lt;address&gt;example.notifications&lt;/address&gt;
             &lt;/queue&gt;
          &lt;/queues&gt;</code>
      </pre>
+     
+     <p>Since we want to lookup the notifications queue using JNDI, we also declare it in  <a href="server0/jbm-jms.xml">jbm-jms.xml</a>
+     <pre>
+         <code>&lt;queue name="notificationsQueue"&gt;
+            &lt;entry name="/queue/notificationsQueue"/&gt;
+         &lt;/queue&gt;</code>
+     </pre>
      <p>The notification queue requires permission to create/delete temporary queues and consume messages.
          This is also configured in <a href="server0/jbm-configuration.xml">jbm-configuration.xml</a></p>
      <pre>
@@ -66,12 +73,12 @@
             MessageProducer producer = session.createProducer(queue);</code>
         </pre>
         
-        <li>We create the JMS management topic. This is a <em>special</em> topic which is not looked up from JNDI but instantiated directly</li>
+        <li>We look up the JMS queue used to receive the notifications from JNDI</li>
         <pre>
-            <code>Topic notificationsTopic = new JBossTopic("example.notifications", "example.notifications");</code>
+            <code>Queue notificationsQueue = (Queue) initialContext.lookup("/queue/notificationsQueue");</code>
         </pre>
 
-        <li>We create a MessageConsumer for the notification topic and set its MessageListener. When a notification is received, we will simply display all the message properties</li>
+        <li>We create a MessageConsumer for the notification queue and set its MessageListener. When a notification is received, we will simply display all the message properties</li>
         <pre>
            <code>MessageConsumer notificationConsumer = session.createConsumer(notificationsTopic);
            notificationConsumer.setMessageListener(new MessageListener()

Modified: trunk/examples/jms/management-notifications/server0/jbm-configuration.xml
===================================================================
--- trunk/examples/jms/management-notifications/server0/jbm-configuration.xml	2009-05-28 12:31:04 UTC (rev 7092)
+++ trunk/examples/jms/management-notifications/server0/jbm-configuration.xml	2009-05-28 12:32:08 UTC (rev 7093)
@@ -6,7 +6,7 @@
 
    <!--  create a default queue for the notification -->     
    <queues>
-      <queue name="example.notifications">
+      <queue name="jms.queue.notificationsQueue">
          <address>example.notifications</address>
       </queue>
    </queues>

Modified: trunk/examples/jms/management-notifications/server0/jbm-jms.xml
===================================================================
--- trunk/examples/jms/management-notifications/server0/jbm-jms.xml	2009-05-28 12:31:04 UTC (rev 7092)
+++ trunk/examples/jms/management-notifications/server0/jbm-jms.xml	2009-05-28 12:32:08 UTC (rev 7093)
@@ -13,4 +13,9 @@
    <queue name="exampleQueue">
       <entry name="/queue/exampleQueue"/>
    </queue>
+
+   <!--the notifications queue used by the example-->
+   <queue name="notificationsQueue">
+      <entry name="/queue/notificationsQueue"/>
+   </queue>
 </configuration>
\ No newline at end of file

Modified: trunk/examples/jms/management-notifications/src/org/jboss/jms/example/ManagementNotificationExample.java
===================================================================
--- trunk/examples/jms/management-notifications/src/org/jboss/jms/example/ManagementNotificationExample.java	2009-05-28 12:31:04 UTC (rev 7092)
+++ trunk/examples/jms/management-notifications/src/org/jboss/jms/example/ManagementNotificationExample.java	2009-05-28 12:32:08 UTC (rev 7093)
@@ -32,12 +32,10 @@
 import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.Session;
-import javax.jms.TextMessage;
 import javax.jms.Topic;
 import javax.naming.InitialContext;
 
 import org.jboss.common.example.JBMExample;
-import org.jboss.messaging.jms.JBossTopic;
 
 /**
  * An example that shows how to receive management notifications using JMS messages.
@@ -60,7 +58,7 @@
          // Step 1. Create an initial context to perform the JNDI lookup.
          initialContext = getContext(0);
 
-         // Step 2. Perfom a lookup on the queue
+         // Step 2. Perform a lookup on the queue
          Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");
          
          // Step 3. Perform a lookup on the Connection Factory
@@ -71,13 +69,12 @@
          Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageProducer producer = session.createProducer(queue);
 
-         // Step 5. create the JMS notification topic.
-         // It is a "special" topic and it is not looked up from JNDI but constructed directly
-         Topic notificationsTopic = new JBossTopic("example.notifications", "example.notifications");
+         // Step 5. Perform a lookup on the notifications queue
+         Queue notificationsQueue = (Queue) initialContext.lookup("/queue/notificationsQueue");
          
-         // Step 6. Create a JMS message consumer for the notification topic and set its message listener
+         // Step 6. Create a JMS message consumer for the notification queue and set its message listener
          // It will display all the properties of the JMS Message
-         MessageConsumer notificationConsumer = session.createConsumer(notificationsTopic);
+         MessageConsumer notificationConsumer = session.createConsumer(notificationsQueue);
          notificationConsumer.setMessageListener(new MessageListener()
          {
             public void onMessage(Message notif)




More information about the jboss-cvs-commits mailing list