Author: sebb
Date: Wed Jun 23 16:32:23 2010
New Revision: 957264

URL: http://svn.apache.org/viewvc?rev=957264&view=rev
Log:
Add JMS Subscriber timeouts

Modified:
    jakarta/jmeter/trunk/docs/images/screenshots/jmspublisher.png
    jakarta/jmeter/trunk/docs/images/screenshots/jmssubscriber.png
    
jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSubscriberGui.java
    
jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/SubscriberSampler.java
    jakarta/jmeter/trunk/xdocs/images/screenshots/jmspublisher.png
    jakarta/jmeter/trunk/xdocs/images/screenshots/jmssubscriber.png
    jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jakarta/jmeter/trunk/docs/images/screenshots/jmspublisher.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/jmspublisher.png?rev=957264&r1=957263&r2=957264&view=diff
==============================================================================
Binary files - no diff available.

Modified: jakarta/jmeter/trunk/docs/images/screenshots/jmssubscriber.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/jmssubscriber.png?rev=957264&r1=957263&r2=957264&view=diff
==============================================================================
Binary files - no diff available.

Modified: 
jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSubscriberGui.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSubscriberGui.java?rev=957264&r1=957263&r2=957264&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSubscriberGui.java
 (original)
+++ 
jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSubscriberGui.java
 Wed Jun 23 16:32:23 2010
@@ -76,6 +76,9 @@ public class JMSSubscriberGui extends Ab
     private final JCheckBox readResponse =
         new JCheckBox(JMeterUtils.getResString("jms_read_response"), true); // 
$NON-NLS-1$
 
+    private JLabeledTextField timeout = 
+        new JLabeledTextField(JMeterUtils.getResString("jms_timeout")); 
//$NON-NLS-1$
+
     //++ Do not change these strings; they are used in JMX files to record the 
button settings
     public final static String RECEIVE_RSC = "jms_subscriber_receive"; // 
$NON-NLS-1$
 
@@ -103,18 +106,7 @@ public class JMSSubscriberGui extends Ab
      */
     public TestElement createTestElement() {
         SubscriberSampler sampler = new SubscriberSampler();
-        this.configureTestElement(sampler);
-        
sampler.setUseJNDIProperties(String.valueOf(useProperties.isSelected()));
-        sampler.setJNDIIntialContextFactory(jndiICF.getText());
-        sampler.setProviderUrl(urlField.getText());
-        sampler.setConnectionFactory(jndiConnFac.getText());
-        sampler.setDestination(jmsDestination.getText());
-        sampler.setUsername(jmsUser.getText());
-        sampler.setPassword(jmsPwd.getText());
-        sampler.setUseAuth(useAuth.isSelected());
-        sampler.setIterations(iterations.getText());
-        sampler.setReadResponse(String.valueOf(readResponse.isSelected()));
-        sampler.setClientChoice(clientChoice.getText());
+        modifyTestElement(sampler);
         return sampler;
     }
 
@@ -137,6 +129,7 @@ public class JMSSubscriberGui extends Ab
         sampler.setIterations(iterations.getText());
         sampler.setReadResponse(String.valueOf(readResponse.isSelected()));
         sampler.setClientChoice(clientChoice.getText());
+        sampler.setTimeout(timeout.getText());
     }
 
     /**
@@ -181,6 +174,7 @@ public class JMSSubscriberGui extends Ab
         commonParams.add(jmsPwd);
         commonParams.add(iterations);
         commonParams.add(readResponse);
+        commonParams.add(timeout);
         commonParams.add(clientChoice);
 
         // we have to add the gui to the change listener
@@ -205,6 +199,7 @@ public class JMSSubscriberGui extends Ab
         useAuth.setSelected(sampler.isUseAuth());
         readResponse.setSelected(sampler.getReadResponseAsBoolean());
         clientChoice.setText(sampler.getClientChoice());
+        timeout.setText(sampler.getTimeout());
     }
 
     @Override
@@ -218,6 +213,7 @@ public class JMSSubscriberGui extends Ab
         jmsUser.setText(""); // $NON-NLS-1$
         jmsPwd.setText(""); // $NON-NLS-1$
         iterations.setText(""); // $NON-NLS-1$
+        timeout.setText("");
         useAuth.setSelected(false);
         readResponse.setSelected(true);
         clientChoice.setText(RECEIVE_RSC);

Modified: 
jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/SubscriberSampler.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/SubscriberSampler.java?rev=957264&r1=957263&r2=957264&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/SubscriberSampler.java
 (original)
+++ 
jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/SubscriberSampler.java
 Wed Jun 23 16:32:23 2010
@@ -47,7 +47,7 @@ import org.apache.log.Logger;
  */
 public class SubscriberSampler extends BaseJMSSampler implements 
Interruptible, TestListener, MessageListener {
 
-    private static final long serialVersionUID = 233L;
+    private static final long serialVersionUID = 240L;
 
     private static final Logger log = LoggingManager.getLoggerForClass();
 
@@ -59,8 +59,12 @@ public class SubscriberSampler extends B
     
     private transient volatile boolean interrupted = false;
 
+    private transient long timeout;
+
     // Don't change the string, as it is used in JMX files
     private static final String CLIENT_CHOICE = "jms.client_choice"; // 
$NON-NLS-1$
+    private static final String TIMEOUT = "jms.timeout"; // $NON-NLS-1$
+    private static final String TIMEOUT_DEFAULT = "";
 
     public SubscriberSampler() {
     }
@@ -102,6 +106,7 @@ public class SubscriberSampler extends B
      *
      */
     private OnMessageSubscriber initListenerClient() throws JMSException, 
NamingException {
+        timeout = getTimeoutAsLong();
         interrupted = false;
         OnMessageSubscriber sub = (OnMessageSubscriber) ClientPool.get(this);
         if (sub == null) {
@@ -125,9 +130,10 @@ public class SubscriberSampler extends B
      * @throws JMSException 
      */
     private void initReceiveClient() throws NamingException, JMSException {
+        timeout = getTimeoutAsLong();
         interrupted = false;
-        SUBSCRIBER = new ReceiveSubscriber(getUseJNDIPropertiesAsBoolean(), 
this
-                .getJNDIInitialContextFactory(), getProviderUrl(), 
getConnectionFactory(), getDestination(),
+        SUBSCRIBER = new ReceiveSubscriber(getUseJNDIPropertiesAsBoolean(),
+                getJNDIInitialContextFactory(), getProviderUrl(), 
getConnectionFactory(), getDestination(),
                 isUseAuth(), getUsername(), getPassword());
         SUBSCRIBER.resume();
         ClientPool.addClient(SUBSCRIBER);
@@ -164,23 +170,30 @@ public class SubscriberSampler extends B
 
         
         result.setSampleLabel(getName());
-        result.sampleStart();
         try {
             initListenerClient();
         } catch (JMSException ex) {
+            result.sampleStart();
             result.sampleEnd();
             result.setResponseCode("000");
             result.setResponseMessage(ex.toString());
             return result;
         } catch (NamingException ex) {
+            result.sampleStart();
             result.sampleEnd();
             result.setResponseCode("000");
             result.setResponseMessage(ex.toString());
             return result;
         }
 
-        
-        while (queue.size() < loop && interrupted == false) {
+        long until = 0L;
+        if (timeout > 0) {
+            until = timeout + System.currentTimeMillis(); 
+        }
+        result.sampleStart();
+        while (!interrupted
+                && (until == 0 || System.currentTimeMillis() < until)
+                && queue.size() < loop) {// check this last as it is the most 
expensive
             try {
                 Thread.sleep(0, 50);
             } catch (InterruptedException e) {
@@ -252,8 +265,14 @@ public class SubscriberSampler extends B
         }
         int loop = getIterationCount();
 
+        long until = 0L;
+        if (timeout > 0) {
+            until = timeout + System.currentTimeMillis(); 
+        }
         result.sampleStart();
-        while (SUBSCRIBER.count(0) < loop && interrupted == false) {
+        while (!interrupted
+                && (until == 0 || System.currentTimeMillis() < until)
+                && SUBSCRIBER.count(0) < loop) { // check this last as it is 
most expensive
             try {
                 Thread.sleep(0, 50);
             } catch (InterruptedException e) {
@@ -349,6 +368,18 @@ public class SubscriberSampler extends B
         return choice;
     }
 
+    public String getTimeout(){
+        return getPropertyAsString(TIMEOUT, TIMEOUT_DEFAULT);
+    }
+
+    public long getTimeoutAsLong(){
+        return getPropertyAsLong(TIMEOUT, 0L);
+    }
+
+    public void setTimeout(String timeout){
+        setProperty(TIMEOUT, timeout, TIMEOUT_DEFAULT);        
+    }
+
     /**
      * Handle an interrupt of the test.
      */

Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/jmspublisher.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/jmspublisher.png?rev=957264&r1=957263&r2=957264&view=diff
==============================================================================
Binary files - no diff available.

Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/jmssubscriber.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/jmssubscriber.png?rev=957264&r1=957263&r2=957264&view=diff
==============================================================================
Binary files - no diff available.

Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=957264&r1=957263&r2=957264&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Wed Jun 23 
16:32:23 2010
@@ -1130,11 +1130,11 @@ For details, see <complink name="BSF Sam
 </properties>
 </component>
 
-<component name="JMS Publisher" index="&sect-num;.1.13"  width="435" 
height="745" screenshot="jmspublisher.png">
-<note>ALPHA CODE</note>
+<component name="JMS Publisher" index="&sect-num;.1.13"  width="513" 
height="742" screenshot="jmspublisher.png">
+<note>BETA CODE - the code is still subject to change</note>
        <description>
                <p>
-               JMS Publisher will publish messages to a given pub/sub topic. 
For those not
+               JMS Publisher will publish messages to a given destination 
(topic/queue). For those not
                familiar with JMS, it is the J2EE specification for messaging. 
There are
                numerous JMS servers on the market and several open source 
options.
                </p>
@@ -1143,24 +1143,47 @@ For details, see <complink name="BSF Sam
        </description>
 <properties>
   <property name="Name" required="">Descriptive name for this element that is 
shown in the tree.</property>
-  <property name="use JNDI properties file" required="Yes">use jndi.properties 
to create topic</property>
+  <property name="use JNDI properties file" required="Yes">use 
jndi.properties. 
+  Note that the file must be on the classpath - e.g. by updating the 
user.classpath JMeter property.
+  </property>
   <property name="JNDI Initial Context Factory" required="No">Name of the 
context factory</property>
-  <property name="Provider URL" required="No">The URL for the jms 
provider</property>
-  <property name="Topic" required="Yes">the message topic</property>
+  <property name="Provider URL" required="Yes, unless using 
jndi.properties">The URL for the jms provider</property>
+  <property name="Destination" required="Yes">the message destination (topic 
or queue name)</property>
   <property name="Authentication" required="Yes">Authentication requirement 
for the JMS provider</property>
   <property name="User" required="No">User Name</property>
   <property name="Password" required="No">Password</property>
   <property name="Number of samples to aggregate" required="Yes">number of 
samples to aggregate</property>
-  <property name="configuration" required="Yes">setting for the 
message</property>
-  <property name="Message type" required="Yes">text or object 
message</property>
+  <property name="Message source" required="Yes">where to obtain the 
message</property>
+  <property name="Message type" required="Yes">Text, Map or Object 
message</property>
 </properties>
+<p>
+For the MapMessage type, JMeter reads the source as lines of text.
+Each line must have 3 fields, delimited by commas.
+The fields are:
+<ul>
+<li>Name of entry</li>
+<li>Object class name, e.g. "String" (assumes java.lang package if not 
specified)</li>
+<li>Object string value</li>
+</ul>
+For each entry, JMeter adds an Object with the given name.
+The value is derived by creating an instance of the class, and using the 
valueOf(String) method to convert the value if necessary.
+For example:
+<pre>
+name,String,Example
+size,Integer,1234
+</pre>
+This is a very simple implementation; it is not intended to support all 
possible object types.
+</p>
+<p>
+<b>Note: </b> the Object message type is not implemented yet.
+</p>
 </component>
 
-<component name="JMS Subscriber" index="&sect-num;.1.14"  width="502" 
height="417" screenshot="jmssubscriber.png">
-<note>ALPHA CODE</note>
+<component name="JMS Subscriber" index="&sect-num;.1.14"  width="513" 
height="441" screenshot="jmssubscriber.png">
+<note>BETA CODE - the code is still subject to change</note>
        <description>
                <p>
-               JMS Publisher will subscribe to messages in a given pub/sub 
topic. For those not
+               JMS Publisher will subscribe to messages in a given destination 
(topic or queue). For those not
                familiar with JMS, it is the J2EE specification for messaging. 
There are
                numerous JMS servers on the market and several open source 
options.
                </p>
@@ -1172,18 +1195,23 @@ For details, see <complink name="BSF Sam
   <property name="use JNDI properties file" required="Yes">use jndi.properties 
to create topic</property>
   <property name="JNDI Initial Context Factory" required="No">Name of the 
context factory</property>
   <property name="Provider URL" required="No">The URL for the jms 
provider</property>
-  <property name="Topic" required="Yes">the message topic</property>
+  <property name="Destination" required="Yes">the message destination (topic 
or queue name)</property>
   <property name="Authentication" required="Yes">Authentication requirement 
for the JMS provider</property>
   <property name="User" required="No">User Name</property>
   <property name="Password" required="No">Password</property>
   <property name="Number of samples to aggregate" required="Yes">number of 
samples to aggregate</property>
-  <property name="Read response" required="Yes">should the sampler read the 
response</property>
+  <property name="Read response" required="Yes">should the sampler read the 
response. If not, only the response length is returned.</property>
+  <property name="Timeout" required="Yes">Specify the timeout to be applied, 
in milliseconds. 0=none. 
+  This is the overall aggregate timeout, not per sample.</property>
   <property name="Client" required="Yes">Which client to use</property>
 </properties>
+<p>
+TBA
+</p>
 </component>
 
 <component name="JMS Point-to-Point" index="&sect-num;.1.15"  width="684" 
height="698" screenshot="jms/JMS_Point-to-Point.png">
-<note>ALPHA CODE</note>
+<note>BETA CODE - the code is still subject to change</note>
        <description>
                <p>
                This sampler sends and optionally receives JMS Messages through 
point-to-point connections (queues).



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to