[jboss-svn-commits] JBL Code SVN: r17186 - in labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_topic_notifier: src/org/jboss/soa/esb/samples/quickstart/helloworldtopicnotifier and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Dec 11 12:48:48 EST 2007


Author: tcunning
Date: 2007-12-11 12:48:48 -0500 (Tue, 11 Dec 2007)
New Revision: 17186

Modified:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_topic_notifier/build.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_topic_notifier/readme.txt
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_topic_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldtopicnotifier/ReceiveJMSMessage.java
Log:
bug:JBESB-1402
Add durable subscriber.


Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_topic_notifier/build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_topic_notifier/build.xml	2007-12-11 16:49:21 UTC (rev 17185)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_topic_notifier/build.xml	2007-12-11 17:48:48 UTC (rev 17186)
@@ -36,8 +36,19 @@
                 <echo>Runs Test ESB Message Receiver</echo>
                 <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.helloworldtopicnotifier.ReceiveJMSMessage" failonerror="true">
                         <arg value="/topic/helloworldtopic"/> <!--  topicName -->
+                        <arg value="non-durable"/> <!--  create a non-durable topic -->
                         <classpath refid="exec-classpath"/>
                 </java>
+	</target>
+	
+	<target name="receive-durable" depends="compile"
+		description="Receives ESB message from topic">
+                <echo>Runs Test ESB Message Receiver</echo>
+                <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.helloworldtopicnotifier.ReceiveJMSMessage" failonerror="true">
+                        <arg value="/topic/helloworldtopic"/> <!--  topicName -->
+			<arg value="durable"/> <!--  create a durable topic -->
+                        <classpath refid="exec-classpath"/>
+                </java>
 
 	</target>
 </project>

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_topic_notifier/readme.txt
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_topic_notifier/readme.txt	2007-12-11 16:49:21 UTC (rev 17185)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_topic_notifier/readme.txt	2007-12-11 17:48:48 UTC (rev 17186)
@@ -4,6 +4,10 @@
   show how to use the Notifier to pass messages to a topic.   This QuickStart 
   sends a message to a queue and the Notifier will pass it to the topic using
   NotifyTopics.      A small utility is included that listens to the topic.
+  
+  If you wish to view the messages sent to the jmx-console, attach a durable
+  subscriber by using the "ant receive-durable" target, and then find the 
+  subscription id by invoking the "listAllSubscriptionAsHTML()" method.
 
 Running this quickstart:
 ========================

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_topic_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldtopicnotifier/ReceiveJMSMessage.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_topic_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldtopicnotifier/ReceiveJMSMessage.java	2007-12-11 16:49:21 UTC (rev 17185)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_topic_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldtopicnotifier/ReceiveJMSMessage.java	2007-12-11 17:48:48 UTC (rev 17186)
@@ -71,8 +71,9 @@
      * Creates a subscriber and attaches a listener
      * @param topicName topic name
      */
-    public void receiveOne(String topicName)
+    public void receiveOne(String topicName, boolean isDurable)
     {
+		TopicSubscriber subscriber = null;
         Properties properties1 = new Properties();
 		properties1.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
 		properties1.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
@@ -85,7 +86,11 @@
 			topicConn = topicFactory.createTopicConnection("guest", "guest");
 			topicConn.setClientID("clientid");
 			topicSession = topicConn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
-			TopicSubscriber subscriber = topicSession.createSubscriber(topic);
+			if (isDurable) {
+				subscriber = topicSession.createDurableSubscriber(topic, "testsub", null, false);
+			} else {
+				subscriber = topicSession.createSubscriber(topic);
+			}
 			ml = new ExListener();
 			subscriber.setMessageListener(ml);
 			topicConn.start();
@@ -99,9 +104,13 @@
     }
     
     public static void main(String args[]) throws Exception
-    {        	    	
+    {        	    
+	if (args.length < 2) {
+		System.err.println("Usage: java ReceiveJMSMessage <topic-name> [durable|non-durable]");
+		System.exit(-1);	
+	}	
     	ReceiveJMSMessage rm = new ReceiveJMSMessage();
-    	rm.receiveOne(args[0]);
+    	rm.receiveOne(args[0], args[1].equals("durable"));
     	while (true) {
     	}
     }




More information about the jboss-svn-commits mailing list