You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jakarta.apache.org by se...@apache.org on 2010/06/23 00:25:56 UTC

svn commit: r957063 - /jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/client/ReceiveSubscriber.java

Author: sebb
Date: Tue Jun 22 22:25:56 2010
New Revision: 957063

URL: http://svn.apache.org/viewvc?rev=957063&view=rev
Log:
Tidy up; drop unused loop count

Modified:
    jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/client/ReceiveSubscriber.java

Modified: jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/client/ReceiveSubscriber.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/client/ReceiveSubscriber.java?rev=957063&r1=957062&r2=957063&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/client/ReceiveSubscriber.java (original)
+++ jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/client/ReceiveSubscriber.java Tue Jun 22 22:25:56 2010
@@ -60,34 +60,21 @@ public class ReceiveSubscriber implement
     //@GuardedBy("this")
     private int counter;
 
-    @SuppressWarnings("unused")
-    private int loop = 1; // TODO never read
-    
     private final ConcurrentLinkedQueue<TextMessage> queue = new ConcurrentLinkedQueue<TextMessage>();
 
-    //@GuardedBy("this")
     private volatile boolean RUN = true;
     // Needs to be volatile to ensure value is picked up
 
     //@GuardedBy("this")
     private Thread CLIENTTHREAD;
 
-    public ReceiveSubscriber(boolean useProps, String jndi, String url, String connfactory, String topic,
+    public ReceiveSubscriber(boolean useProps, String jndi, String url, String connfactory, String destinationName,
             boolean useAuth, String user, String pwd) throws NamingException, JMSException {
         Context ctx = InitialContextFactory.getContext(useProps, jndi, url, useAuth, user, pwd);
         CONN = Utils.getConnection(ctx, connfactory);
-        Destination _topic = Utils.lookupDestination(ctx, topic);
         SESSION = CONN.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        SUBSCRIBER = SESSION.createConsumer(_topic);
-    }
-
-    /**
-     * Set the number of iterations for each call to sample()
-     *
-     * @param loop
-     */
-    public void setLoop(int loop) {
-        this.loop = loop;
+        Destination dest = Utils.lookupDestination(ctx, destinationName);
+        SUBSCRIBER = SESSION.createConsumer(dest);
     }
 
     /**
@@ -152,11 +139,6 @@ public class ReceiveSubscriber implement
      * created, it calls Thread.start().
      */
     public void start() {
-        // No point starting thread unless subscriber exists
-        if (SUBSCRIBER == null) {
-            log.error("Subscriber has not been set up");
-            return;
-        }
         this.CLIENTTHREAD = new Thread(this, "Subscriber2");
         this.CLIENTTHREAD.start();
     }
@@ -169,16 +151,14 @@ public class ReceiveSubscriber implement
      * 
      */
     public void run() {
-        if (SUBSCRIBER == null) { // just in case
-            log.error("Subscriber has not been set up");
-            return;
-        }
         while (RUN) {
             try {
                 Message message = this.SUBSCRIBER.receive();
-                if (message != null && message instanceof TextMessage) {
+                if (message instanceof TextMessage) {
                     queue.add((TextMessage)message);
                     count(1);
+                } else if (message != null){
+                	log.warn("Discarded non TextMessage " +  message);
                 }
             } catch (JMSException e) {
                 log.error("Communication error: " + e.getMessage());



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@jakarta.apache.org
For additional commands, e-mail: notifications-help@jakarta.apache.org