jakarta-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1082871 - in /jakarta/jmeter/trunk: docs/images/screenshots/ src/core/org/apache/jmeter/resources/ src/protocol/jms/org/apache/jmeter/protocol/jms/client/ src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/ src/protocol/jms/org/ap...
Date Fri, 18 Mar 2011 11:35:59 GMT
Author: sebb
Date: Fri Mar 18 11:35:58 2011
New Revision: 1082871

URL: http://svn.apache.org/viewvc?rev=1082871&view=rev
Log:
Bug 50666 - JMSSubscriber: support for durable subscriptions

Modified:
    jakarta/jmeter/trunk/docs/images/screenshots/jmssubscriber.png
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/client/ReceiveSubscriber.java
    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/changes.xml
    jakarta/jmeter/trunk/xdocs/images/screenshots/jmssubscriber.png
    jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml

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

Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1082871&r1=1082870&r2=1082871&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Fri Mar
18 11:35:58 2011
@@ -341,6 +341,7 @@ jms_correlation_title=Use alternate fiel
 jms_dest_setup=Setup
 jms_dest_setup_dynamic=Each sample
 jms_dest_setup_static=At startup
+jms_durable_subscription_id=Durable Subscription ID
 jms_error_msg=Object message should read from an external file. Text input is currently selected,
please remember to change it.
 jms_file=File
 jms_initial_context_factory=Initial Context Factory

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=1082871&r1=1082870&r2=1082871&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
Fri Mar 18 11:35:58 2011
@@ -29,6 +29,7 @@ import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageListener;
 import javax.jms.Session;
+import javax.jms.Topic;
 import javax.naming.Context;
 import javax.naming.NamingException;
 
@@ -81,14 +82,14 @@ public class ReceiveSubscriber implement
      */
     public ReceiveSubscriber(boolean useProps, 
             String initialContextFactory, String providerUrl, String connfactory, String
destinationName,
-            boolean useAuth, 
+            String durableSubscriptionId, boolean useAuth, 
             String securityPrincipal, String securityCredentials) throws NamingException,
JMSException {
         Context ctx = InitialContextFactory.getContext(useProps, 
                 initialContextFactory, providerUrl, useAuth, securityPrincipal, securityCredentials);
         CONN = Utils.getConnection(ctx, connfactory);
         SESSION = CONN.createSession(false, Session.AUTO_ACKNOWLEDGE);
         Destination dest = Utils.lookupDestination(ctx, destinationName);
-        SUBSCRIBER = SESSION.createConsumer(dest);
+       	SUBSCRIBER = createSubscriber(SESSION, dest, durableSubscriptionId);
         queue = null;
         log.debug("<init> complete");
     }
@@ -114,14 +115,14 @@ public class ReceiveSubscriber implement
      */
     public ReceiveSubscriber(int queueSize, boolean useProps, 
             String initialContextFactory, String providerUrl, String connfactory, String
destinationName,
-            boolean useAuth, 
+            String durableSubscriptionId, boolean useAuth, 
             String securityPrincipal, String securityCredentials) throws NamingException,
JMSException {
         Context ctx = InitialContextFactory.getContext(useProps, 
                 initialContextFactory, providerUrl, useAuth, securityPrincipal, securityCredentials);
         CONN = Utils.getConnection(ctx, connfactory);
         SESSION = CONN.createSession(false, Session.AUTO_ACKNOWLEDGE);
         Destination dest = Utils.lookupDestination(ctx, destinationName);
-        SUBSCRIBER = SESSION.createConsumer(dest);
+        SUBSCRIBER = createSubscriber(SESSION, dest, durableSubscriptionId);
         if (queueSize <=0) {
             queue = new LinkedBlockingQueue<Message>();
         } else {
@@ -130,6 +131,27 @@ public class ReceiveSubscriber implement
         SUBSCRIBER.setMessageListener(this);
         log.debug("<init> complete");
     }
+    
+    /**
+     * Return a simple MessageConsumer or a TopicSubscriber (as a durable subscription)
+     * @param session
+     * 				JMS session	
+     * @param destination
+     * 				JMS destination, can be either topic or queue
+     * @param durableSubscriptionId 
+     * 				If neither empty nor null, this means that a durable 
+     * 				subscription will be used
+     * @return
+     * @throws JMSException
+     */
+    private MessageConsumer createSubscriber(Session session, 
+    		Destination destination, String durableSubscriptionId) throws JMSException {
+    	if (isEmpty(durableSubscriptionId)) {
+        	return  session.createConsumer(destination);
+        } else {
+        	return session.createDurableSubscriber((Topic) destination, durableSubscriptionId);

+        }	
+    }
 
     /**
      * Calls Connection.start() to begin receiving inbound messages.
@@ -204,4 +226,16 @@ public class ReceiveSubscriber implement
             log.warn("Could not add message to queue");
         }
     }
+    
+    
+    /**
+     * Checks whether string is empty
+     * 
+     * @param s1
+     * @return True if input is null, an empty string, 
+     * 				or a white space-only string
+     */
+    private boolean isEmpty(String s1) {
+    	return (s1 == null || s1.trim().equals(""));
+    }
 }

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=1082871&r1=1082870&r2=1082871&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
Fri Mar 18 11:35:58 2011
@@ -58,6 +58,9 @@ public class JMSSubscriberGui extends Ab
 
     private final JLabeledTextField jmsDestination =
         new JLabeledTextField(JMeterUtils.getResString("jms_topic")); // $NON-NLS-1$
+    
+    private final JLabeledTextField jmsDurableSubscriptionId =
+        new JLabeledTextField(JMeterUtils.getResString("jms_durable_subscription_id")); //
$NON-NLS-1$
 
     private final JLabeledTextField jmsUser =
         new JLabeledTextField(JMeterUtils.getResString("jms_user")); // $NON-NLS-1$
@@ -132,6 +135,7 @@ public class JMSSubscriberGui extends Ab
         sampler.setProviderUrl(urlField.getText());
         sampler.setConnectionFactory(jndiConnFac.getText());
         sampler.setDestination(jmsDestination.getText());
+        sampler.setDurableSubscriptionId(jmsDurableSubscriptionId.getText());
         sampler.setUsername(jmsUser.getText());
         sampler.setPassword(jmsPwd.getText());
         sampler.setUseAuth(useAuth.isSelected());
@@ -164,6 +168,7 @@ public class JMSSubscriberGui extends Ab
         mainPanel.add(urlField);
         mainPanel.add(jndiConnFac);
         mainPanel.add(createDestinationPane());
+        mainPanel.add(jmsDurableSubscriptionId);
         mainPanel.add(useAuth);
         mainPanel.add(jmsUser);
         mainPanel.add(jmsPwd);
@@ -193,6 +198,7 @@ public class JMSSubscriberGui extends Ab
         urlField.setText(sampler.getProviderUrl());
         jndiConnFac.setText(sampler.getConnectionFactory());
         jmsDestination.setText(sampler.getDestination());
+        jmsDurableSubscriptionId.setText(sampler.getDurableSubscriptionId());
         jmsUser.setText(sampler.getUsername());
         jmsPwd.setText(sampler.getPassword());
         iterations.setText(sampler.getIterations());
@@ -212,6 +218,7 @@ public class JMSSubscriberGui extends Ab
         urlField.setText(""); // $NON-NLS-1$
         jndiConnFac.setText(""); // $NON-NLS-1$
         jmsDestination.setText(""); // $NON-NLS-1$
+        jmsDurableSubscriptionId.setText(""); // $NON-NLS-1$
         jmsUser.setText(""); // $NON-NLS-1$
         jmsPwd.setText(""); // $NON-NLS-1$
         iterations.setText("1"); // $NON-NLS-1$

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=1082871&r1=1082870&r2=1082871&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
Fri Mar 18 11:35:58 2011
@@ -36,7 +36,7 @@ import org.apache.jorphan.logging.Loggin
 import org.apache.log.Logger;
 
 /**
- * This class implements the JMS Subcriber sampler.
+ * This class implements the JMS Subscriber sampler.
  * It supports both receive and onMessage strategies via the ReceiveSubscriber class.
  * 
  */
@@ -55,7 +55,7 @@ public class SubscriberSampler extends B
     private static final Logger log = LoggingManager.getLoggerForClass();
 
     // Default wait (ms) for a message if timeouts are not enabled
-    // This is the maximimum time the sampler can be blocked.
+    // This is the maximum time the sampler can be blocked.
     private static final long DEFAULT_WAIT = 500L;
 
     // No need to synch/ - only used by sampler and ClientPool (which does its own synch)
@@ -64,10 +64,10 @@ public class SubscriberSampler extends B
     private transient volatile boolean interrupted = false;
 
     private transient long timeout;
-
+    
     private transient boolean useReceive;
 
-    // This will be null iff initialisation succeeeds.
+    // This will be null if initialization succeeds.
     private transient Exception exceptionDuringInit;
 
     // If true, start/stop subscriber for each sample
@@ -77,6 +77,8 @@ public class SubscriberSampler extends B
     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 = "";
+    private static final String DURABLE_SUBSCRIPTION_ID = "jms.durableSubscriptionId"; //
$NON-NLS-1$
+    private static final String DURABLE_SUBSCRIPTION_ID_DEFAULT = "";
     private static final String STOP_BETWEEN = "jms.stop_between_samples"; // $NON-NLS-1$
     
     private transient boolean START_ON_SAMPLE = false;
@@ -93,7 +95,7 @@ public class SubscriberSampler extends B
      */
     private void initListenerClient() throws JMSException, NamingException {
         SUBSCRIBER = new ReceiveSubscriber(0, getUseJNDIPropertiesAsBoolean(), getJNDIInitialContextFactory(),
-                    getProviderUrl(), getConnectionFactory(), getDestination(), 
+                    getProviderUrl(), getConnectionFactory(), getDestination(), getDurableSubscriptionId(),
                     isUseAuth(), getUsername(), getPassword());
         log.debug("SubscriberSampler.initListenerClient called");
     }
@@ -106,7 +108,7 @@ public class SubscriberSampler extends B
     private void initReceiveClient() throws NamingException, JMSException {
         SUBSCRIBER = new ReceiveSubscriber(getUseJNDIPropertiesAsBoolean(),
                 getJNDIInitialContextFactory(), getProviderUrl(), getConnectionFactory(),
getDestination(),
-                isUseAuth(), getUsername(), getPassword());
+                getDurableSubscriptionId(), isUseAuth(), getUsername(), getPassword());
         log.debug("SubscriberSampler.initReceiveClient called");
     }
 
@@ -353,6 +355,14 @@ public class SubscriberSampler extends B
     public void setTimeout(String timeout){
         setProperty(TIMEOUT, timeout, TIMEOUT_DEFAULT);        
     }
+    
+    public String getDurableSubscriptionId(){
+        return getPropertyAsString(DURABLE_SUBSCRIPTION_ID);
+    }
+
+    public void setDurableSubscriptionId(String durableSubscriptionId){
+        setProperty(DURABLE_SUBSCRIPTION_ID, durableSubscriptionId, DURABLE_SUBSCRIPTION_ID_DEFAULT);
       
+    }
 
     // This was the old value that was checked for
     private final static String RECEIVE_STR = JMeterUtils.getResString(JMSSubscriberGui.RECEIVE_RSC);
// $NON-NLS-1$

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=1082871&r1=1082870&r2=1082871&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Fri Mar 18 11:35:58 2011
@@ -157,6 +157,7 @@ Fixed RMI startup to provide location of
 <li>Bug 49862 - Improve SMTPSampler Request output.</li>
 <li>Bug 50268 - Adds static and dynamic destinations to JMS Publisher</li>
 <li>JMS Subscriber - Add dynamic destination</li>
+<li>Bug 50666 - JMSSubscriber: support for durable subscriptions</li>
 </ul>
 
 <h3>Controllers</h3>

Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/jmssubscriber.png
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/jmssubscriber.png?rev=1082871&r1=1082870&r2=1082871&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=1082871&r1=1082870&r2=1082871&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Fri Mar 18 11:35:58 2011
@@ -1236,6 +1236,8 @@ The following table shows some values wh
   <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="Destination" required="Yes">the message destination (topic or queue
name)</property>
+  <property name="Durable Subscription ID" required="No">The ID to use for a durable
subscription. On first 
+  use the respective queue will automatically be generated by the JMS provider if it does
not exist yet.</property>
   <property name="Setup" required="Yes">The destination setup type. With At startup,
the destination name is static (i.e. always same name during the test), with Each sample,
the destination name is dynamic and is evaluate at each sample (i.e. the destination name
may be a variable)</property>
   <property name="Authentication" required="Yes">Authentication requirement for the
JMS provider</property>
   <property name="User" required="No">User Name</property>



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


Mime
View raw message