[jboss-cvs] JBoss Messaging SVN: r6734 - in trunk/examples/jms/management: src/org/jboss/jms/example and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon May 11 11:46:32 EDT 2009


Author: jmesnil
Date: 2009-05-11 11:46:31 -0400 (Mon, 11 May 2009)
New Revision: 6734

Modified:
   trunk/examples/jms/management/readme.html
   trunk/examples/jms/management/src/org/jboss/jms/example/ManagementExample.java
Log:
management refactoring

* updated management example

Modified: trunk/examples/jms/management/readme.html
===================================================================
--- trunk/examples/jms/management/readme.html	2009-05-11 13:01:31 UTC (rev 6733)
+++ trunk/examples/jms/management/readme.html	2009-05-11 15:46:31 UTC (rev 6734)
@@ -104,12 +104,12 @@
         
         <li>We send the <em>management</em> message using the requestor and wait for a reply</li>
         <pre>
-            <code>ObjectMessage reply = (ObjectMessage)requestor.request(m);</code>
+            <code>Message reply = requestor.request(m);</code>
         </pre>
         
-        <li>The attribute value is returned as the body of an <code>ObjectMessage</code> (in this case, the <code>MessageCount</code> is an integer)
+        <li>We use a helper class <a href="../../../docs/api/org/jboss/messaging/jms/server/management/impl/JMSManagementHelper.html">JMSManagementHelper</a> to retrieve the result from the reply message:
         <pre>
-            <code>int messageCount = (Integer) reply.getObject();
+            <code>int messageCount = (Integer)JMSManagementHelper.getResult(reply);
             System.out.println(queue.getQueueName() + " contains " + messageCount + " messages");</code>
         </pre>
         
@@ -131,7 +131,7 @@
         
         <li>Again, we use the requestor to send the management message and wait for a reply</li>
         <pre>
-            <code>reply = (ObjectMessage)requestor.request(m);</code>
+            <code>reply = requestor.request(m);</code>
         </pre>
         
         <li>We use the helper class to check that the operation was successfully invoked on the server</li>
@@ -140,10 +140,10 @@
             System.out.println("operation invocation has succeeded: " + success);</code>
         </pre>
         
-        <li>The return value of the operation invocation is returned as the body of an ObjectMessage
+        <li>We use a helper class <a href="../../../docs/api/org/jboss/messaging/jms/server/management/impl/JMSManagementHelper.html">JMSManagementHelper</a> to retrieve the result from the reply message:
             (in our case, the <code>removeMessage</code> method returns a boolean)</li>
         <pre>
-            <code>boolean messageRemoved = (Boolean) reply.getObject();
+            <code>boolean messageRemoved = (Boolean)JMSManagementHelper.getResult(reply);
             System.out.println("message has been removed: " + messageRemoved);</code>
         </pre>
             

Modified: trunk/examples/jms/management/src/org/jboss/jms/example/ManagementExample.java
===================================================================
--- trunk/examples/jms/management/src/org/jboss/jms/example/ManagementExample.java	2009-05-11 13:01:31 UTC (rev 6733)
+++ trunk/examples/jms/management/src/org/jboss/jms/example/ManagementExample.java	2009-05-11 15:46:31 UTC (rev 6734)
@@ -99,10 +99,10 @@
          JMSManagementHelper.putAttribute(m, "jms.queue.exampleQueue", "MessageCount");
          
          // Step 14. Use the requestor to send the request and wait for the reply
-         ObjectMessage reply = (ObjectMessage)requestor.request(m);
+         Message reply = requestor.request(m);
 
-         // Step 15. The attribute value is returned as the body of an ObjectMessage (in this case, an integer)
-         int messageCount = (Integer) reply.getObject();
+         // Step 15. Use a helper class to retrieve the operation result
+         int messageCount = (Integer)JMSManagementHelper.getResult(reply);
          System.out.println(queue.getQueueName() + " contains " + messageCount + " messages");
          
          // Step 16. Create another JMS message to use as a management message
@@ -115,15 +115,15 @@
          JMSManagementHelper.putOperationInvocation(m, "jms.queue.exampleQueue", "removeMessage", message.getJMSMessageID());
 
          // Step 18 Use the requestor to send the request and wait for the reply
-         reply = (ObjectMessage)requestor.request(m);
+         reply = requestor.request(m);
          
          // Step 19. Use a helper class to check that the operation has succeeded
          boolean success = JMSManagementHelper.hasOperationSucceeded(reply);
          System.out.println("operation invocation has succeeded: " + success);
 
-         // Step 20. The return value of the operation invocation is returned as the body of an ObjectMessage
+         // Step 20. Use a helper class to retrieve the operation result
          // in that case, a boolean which is true if the message was removed, false else
-         boolean messageRemoved = (Boolean) reply.getObject();
+         boolean messageRemoved = (Boolean)JMSManagementHelper.getResult(reply);
          System.out.println("message has been removed: " + messageRemoved);
          
          // Step 21. Create a JMS Message Consumer on the queue




More information about the jboss-cvs-commits mailing list