jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1607183 - in /jmeter/trunk: src/core/org/apache/jmeter/resources/ src/protocol/jms/org/apache/jmeter/protocol/jms/ src/protocol/jms/org/apache/jmeter/protocol/jms/client/ src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/ src/pro...
Date Tue, 01 Jul 2014 20:54:08 GMT
Author: pmouawad
Date: Tue Jul  1 20:54:07 2014
New Revision: 1607183

URL: http://svn.apache.org/r1607183
Log:
Bug 56510 - JMS Publisher/Point to Point: Add JMSPriority and JMSExpiration
Bugzilla Id: 56510

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
    jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/Utils.java
    jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/client/Publisher.java
    jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSPublisherGui.java
    jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSamplerGui.java
    jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/FixedQueueExecutor.java
    jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java
    jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/PublisherSampler.java
    jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/QueueExecutor.java
    jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/TemporaryQueueExecutor.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1607183&r1=1607182&r2=1607183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Tue Jul  1 20:54:07
2014
@@ -440,6 +440,7 @@ jms_dest_setup=Setup
 jms_dest_setup_dynamic=Each sample
 jms_dest_setup_static=At startup
 jms_durable_subscription_id=Durable Subscription ID
+jms_expiration=Expiration
 jms_file=File
 jms_initial_context_factory=Initial Context Factory
 jms_itertions=Number of samples to aggregate
@@ -451,6 +452,7 @@ jms_message_type=Message Type
 jms_msg_content=Content
 jms_object_message=Object Message
 jms_point_to_point=JMS Point-to-Point
+jms_priority=Priority
 jms_properties=JMS Properties
 jms_properties_title=JMS Properties
 jms_properties_name=Name

Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=1607183&r1=1607182&r2=1607183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties Tue Jul  1 20:54:07
2014
@@ -434,6 +434,7 @@ jms_dest_setup=Evaluer
 jms_dest_setup_dynamic=A chaque \u00E9chantillon
 jms_dest_setup_static=Au d\u00E9marrage
 jms_durable_subscription_id=ID d'abonnement durable
+jms_expiration=Expiration
 jms_file=Fichier
 jms_initial_context_factory=Fabrique de connexion initiale
 jms_itertions=Nombre d'\u00E9chantillons \u00E0 agr\u00E9ger
@@ -445,6 +446,7 @@ jms_message_type=Type de message \: 
 jms_msg_content=Contenu
 jms_object_message=Message Object
 jms_point_to_point=Requ\u00EAte JMS Point-\u00E0-point
+jms_priority=Priorit\u00E9
 jms_properties=Propri\u00E9t\u00E9s JMS
 jms_properties_title=Propri\u00E9t\u00E9s JMS
 jms_properties_type=Classe de la Valeur

Modified: jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/Utils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/Utils.java?rev=1607183&r1=1607182&r2=1607183&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/Utils.java (original)
+++ jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/Utils.java Tue Jul  1 20:54:07
2014
@@ -42,6 +42,14 @@ import org.apache.log.Logger;
  * WARNING - the API for this class is likely to change!
  */
 public final class Utils {
+    // By default priority is 4
+    // http://docs.oracle.com/javaee/6/tutorial/doc/bncfu.html
+    public static final int DEFAULT_PRIORITY_4 = 4;
+
+    // By default a message never expires
+    // http://docs.oracle.com/javaee/6/tutorial/doc/bncfu.html
+    public static final long DEFAULT_NO_EXPIRY = 0L;
+
     private static final Logger log = LoggingManager.getLoggerForClass();
 
     public static void close(MessageConsumer closeable, Logger log){

Modified: jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/client/Publisher.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/client/Publisher.java?rev=1607183&r1=1607182&r2=1607183&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/client/Publisher.java (original)
+++ jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/client/Publisher.java Tue
Jul  1 20:54:07 2014
@@ -25,7 +25,6 @@ import java.util.Map.Entry;
 
 import javax.jms.BytesMessage;
 import javax.jms.Connection;
-import javax.jms.DeliveryMode;
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.MapMessage;
@@ -49,13 +48,12 @@ public class Publisher implements Closea
 
     private final Session session;
 
-    private final  MessageProducer producer;
+    private final MessageProducer producer;
     
     private final Context ctx;
     
     private final boolean staticDest;
 
-
     /**
      * Create a publisher using either the jndi.properties file or the provided parameters.
      * Uses a static destination and persistent messages(for backward compatibility)
@@ -76,32 +74,9 @@ public class Publisher implements Closea
             String securityPrincipal, String securityCredentials) throws JMSException, NamingException
{
         this(useProps, initialContextFactory, providerUrl, connfactory,
                 destinationName, useAuth, securityPrincipal,
-                securityCredentials, true, false);
+                securityCredentials, true);
     }
     
-    /**
-     * Create a publisher using either the jndi.properties file or the provided parameters.
-     * Uses a static destination (for backward compatibility)
-     * 
-     * @param useProps true if a jndi.properties file is to be used
-     * @param initialContextFactory the (ignored if useProps is true)
-     * @param providerUrl (ignored if useProps is true)
-     * @param connfactory
-     * @param destinationName
-     * @param useAuth (ignored if useProps is true)
-     * @param securityPrincipal (ignored if useProps is true)
-     * @param securityCredentials (ignored if useProps is true)
-     * @param useNonPersistentMessages Flag Delivery Mode as Non persistent if true
-     * @throws JMSException if the context could not be initialised, or there was some other
error
-     * @throws NamingException 
-     */
-    public Publisher(boolean useProps, String initialContextFactory, String providerUrl,

-            String connfactory, String destinationName, boolean useAuth,
-            String securityPrincipal, String securityCredentials, boolean useNonPersistentMessages)
throws JMSException, NamingException {
-        this(useProps, initialContextFactory, providerUrl, connfactory,
-                destinationName, useAuth, securityPrincipal,
-                securityCredentials, true, useNonPersistentMessages);
-    }
     
     /**
      * Create a publisher using either the jndi.properties file or the provided parameters
@@ -114,14 +89,13 @@ public class Publisher implements Closea
      * @param securityPrincipal (ignored if useProps is true)
      * @param securityCredentials (ignored if useProps is true)
      * @param staticDestination true is the destination is not to change between loops
-     * @param useNonPersistentMessages Flag Delivery Mode as Non persistent if true
      * @throws JMSException if the context could not be initialised, or there was some other
error
      * @throws NamingException 
      */
     public Publisher(boolean useProps, String initialContextFactory, String providerUrl,

             String connfactory, String destinationName, boolean useAuth,
             String securityPrincipal, String securityCredentials,
-            boolean staticDestination,  boolean useNonPersistentMessages) throws JMSException,
NamingException {
+            boolean staticDestination) throws JMSException, NamingException {
         super();
         boolean initSuccess = false;
         try{
@@ -136,9 +110,6 @@ public class Publisher implements Closea
             } else {
                 producer = session.createProducer(null);
             }
-            if(useNonPersistentMessages) {
-                producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-            }
             initSuccess = true;
         } finally {
             if(!initSuccess) {
@@ -146,82 +117,57 @@ public class Publisher implements Closea
             }
         }
     }
-
-    public Message publish(String text) throws JMSException,
-            NamingException {
-        return publish(text, null, null);
-    }
     
-    public Message publish(String text, String destinationName)
-            throws JMSException, NamingException {
-        return publish(text, destinationName, null);
-    }
-    
-    public Message publish(String text, String destinationName, Map<String, Object>
properties)
+    public Message publish(String text, String destinationName, Map<String, Object>
properties, int deliveryMode, int priority, long expiration)
             throws JMSException, NamingException {
         TextMessage msg = session.createTextMessage(text);
-        return setPropertiesAndSend(destinationName, properties, msg);
-    }
-    
-    public Message publish(Serializable contents) throws JMSException,
-            NamingException {
-        return publish(contents, null);
-    }
-
-    public Message publish(Serializable contents, String destinationName) 
-            throws JMSException, NamingException {
-        return publish(contents, destinationName, null);
+        return setPropertiesAndSend(destinationName, properties, msg, deliveryMode, priority,
expiration);
     }
     
-    public Message publish(Serializable contents, String destinationName, Map<String,
Object> properties)
+    public Message publish(Serializable contents, String destinationName, Map<String,
Object> properties, int deliveryMode, int priority, long expiration)
             throws JMSException, NamingException {
         ObjectMessage msg = session.createObjectMessage(contents);
-        return setPropertiesAndSend(destinationName, properties, msg);
+        return setPropertiesAndSend(destinationName, properties, msg, deliveryMode, priority,
expiration);
     }
     
-    public Message publish(byte[] bytes, String destinationName, Map<String, Object>
properties)
+    public Message publish(byte[] bytes, String destinationName, Map<String, Object>
properties, int deliveryMode, int priority, long expiration)
             throws JMSException, NamingException {
         BytesMessage msg = session.createBytesMessage();
         msg.writeBytes(bytes);
-        return setPropertiesAndSend(destinationName, properties, msg);
-    }
-
-    public Message publish(Map<String, Object> map) throws JMSException,
-            NamingException {
-        return publish(map, null, null);
-    }
-    
-    public Message publish(Map<String, Object> map, String destinationName)
-            throws JMSException, NamingException {
-        return publish(map, destinationName, null);
+        return setPropertiesAndSend(destinationName, properties, msg, deliveryMode, priority,
expiration);
     }
     
-    public MapMessage publish(Map<String, Object> map, String destinationName, Map<String,
Object> properties)
+    public MapMessage publish(Map<String, Object> map, String destinationName, Map<String,
Object> properties, 
+            int deliveryMode, int priority, long expiration)
             throws JMSException, NamingException {
         MapMessage msg = session.createMapMessage();
         for (Entry<String, Object> me : map.entrySet()) {
             msg.setObject(me.getKey(), me.getValue());
         }
-        return (MapMessage)setPropertiesAndSend(destinationName, properties, msg);
+        return (MapMessage)setPropertiesAndSend(destinationName, properties, msg, deliveryMode,
priority, expiration);
     }
 
     /**
      * @param destinationName 
      * @param properties Map<String, String>
      * @param msg Message
+     * @param deliveryMode
+     * @param priority
+     * @param expiration
      * @return Message
      * @throws JMSException
      * @throws NamingException
      */
     private Message setPropertiesAndSend(String destinationName,
-            Map<String, Object> properties, Message msg)
+            Map<String, Object> properties, Message msg,
+            int deliveryMode, int priority, long expiration)
             throws JMSException, NamingException {
         Utils.addJMSProperties(msg, properties);
         if (staticDest || destinationName == null) {
-            producer.send(msg);
+            producer.send(msg, deliveryMode, priority, expiration);
         } else {
             Destination dest = Utils.lookupDestination(ctx, destinationName);
-            producer.send(dest, msg);
+            producer.send(dest, msg, deliveryMode, priority, expiration);
         }
         return msg;
     }

Modified: jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSPublisherGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSPublisherGui.java?rev=1607183&r1=1607182&r2=1607183&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSPublisherGui.java
(original)
+++ jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSPublisherGui.java
Tue Jul  1 20:54:07 2014
@@ -29,6 +29,7 @@ import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 
 import org.apache.jmeter.gui.util.FilePanel;
+import org.apache.jmeter.gui.util.HorizontalPanel;
 import org.apache.jmeter.gui.util.JLabeledRadioI18N;
 import org.apache.jmeter.gui.util.JSyntaxTextArea;
 import org.apache.jmeter.gui.util.JTextScrollPane;
@@ -89,6 +90,10 @@ public class JMSPublisherGui extends Abs
 
     private final JLabeledTextField jmsDestination = new JLabeledTextField(JMeterUtils.getResString("jms_topic"));
//$NON-NLS-1$
 
+    private final JLabeledTextField expiration = new JLabeledTextField(JMeterUtils.getResString("jms_expiration"),10);
//$NON-NLS-1$
+
+    private final JLabeledTextField priority = new JLabeledTextField(JMeterUtils.getResString("jms_priority"),1);
//$NON-NLS-1$
+
     private final JCheckBox useAuth = new JCheckBox(JMeterUtils.getResString("jms_use_auth"),
false); //$NON-NLS-1$
 
     private final JLabeledTextField jmsUser = new JLabeledTextField(JMeterUtils.getResString("jms_user"));
//$NON-NLS-1$
@@ -165,6 +170,8 @@ public class JMSPublisherGui extends Abs
       sampler.setProviderUrl(urlField.getText());
       sampler.setConnectionFactory(jndiConnFac.getText());
       sampler.setDestination(jmsDestination.getText());
+      sampler.setExpiration(expiration.getText());
+      sampler.setPriority(priority.getText());
       sampler.setUsername(jmsUser.getText());
       sampler.setPassword(jmsPwd.getText());
       sampler.setTextMessage(textMessage.getText());
@@ -198,6 +205,7 @@ public class JMSPublisherGui extends Abs
         mainPanel.add(jndiConnFac);
         mainPanel.add(createDestinationPane());
         mainPanel.add(createAuthPane());
+        mainPanel.add(createPriorityAndExpiration());
         mainPanel.add(iterations);
 
         jmsPropertiesPanel = new JMSPropertiesPanel(); //$NON-NLS-1$
@@ -229,6 +237,8 @@ public class JMSPublisherGui extends Abs
         urlField.setText(""); // $NON-NLS-1$
         jndiConnFac.setText(""); // $NON-NLS-1$
         jmsDestination.setText(""); // $NON-NLS-1$
+        expiration.setText(""); // $NON-NLS-1$
+        priority.setText(""); // $NON-NLS-1$
         jmsUser.setText(""); // $NON-NLS-1$
         jmsPwd.setText(""); // $NON-NLS-1$
         textMessage.setInitialText(""); // $NON-NLS-1$
@@ -268,6 +278,8 @@ public class JMSPublisherGui extends Abs
         configChoice.setText(sampler.getConfigChoice());
         msgChoice.setText(sampler.getMessageChoice());
         iterations.setText(sampler.getIterations());
+        expiration.setText(sampler.getExpiration());
+        priority.setText(sampler.getPriority());
         useAuth.setSelected(sampler.isUseAuth());
         jmsUser.setEnabled(useAuth.isSelected());
         jmsPwd.setEnabled(useAuth.isSelected());
@@ -364,4 +376,14 @@ public class JMSPublisherGui extends Abs
         pane.add(jmsPwd);
         return pane;
     }
+
+    /**
+     * @return JPanel Panel for priority and expiration
+     */
+    private JPanel createPriorityAndExpiration() {
+        JPanel panel = new HorizontalPanel();
+        panel.add(expiration);
+        panel.add(priority);
+        return panel;
+    }
 }

Modified: jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSamplerGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSamplerGui.java?rev=1607183&r1=1607182&r2=1607183&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSamplerGui.java
(original)
+++ jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSamplerGui.java
Tue Jul  1 20:54:07 2014
@@ -56,7 +56,11 @@ public class JMSSamplerGui extends Abstr
 
     private JLabeledTextField receiveQueue = new JLabeledTextField(JMeterUtils.getResString("jms_receive_queue"));
//$NON-NLS-1$
 
-    private JLabeledTextField timeout = new JLabeledTextField(JMeterUtils.getResString("jms_timeout"));
//$NON-NLS-1$
+    private JLabeledTextField timeout = new JLabeledTextField(JMeterUtils.getResString("jms_timeout"),10);
//$NON-NLS-1$
+
+    private JLabeledTextField expiration = new JLabeledTextField(JMeterUtils.getResString("jms_expiration"),10);
//$NON-NLS-1$
+
+    private JLabeledTextField priority = new JLabeledTextField(JMeterUtils.getResString("jms_priority"),1);
//$NON-NLS-1$
 
     private JLabeledTextField jmsSelector = new JLabeledTextField(JMeterUtils.getResString("jms_selector"));
//$NON-NLS-1$
 
@@ -97,6 +101,8 @@ public class JMSSamplerGui extends Abstr
         receiveQueue.setText(""); // $NON-NLS-1$
         ((JComboBox) oneWay.getComponentList().get(1)).setSelectedItem(JMeterUtils.getResString("jms_request"));
//$NON-NLS-1$
         timeout.setText("");  // $NON-NLS-1$
+        expiration.setText("");  // $NON-NLS-1$
+        priority.setText("");  // $NON-NLS-1$
         jmsSelector.setText(""); // $NON-NLS-1$
         messageContent.setInitialText(""); // $NON-NLS-1$
         initialContextFactory.setText(""); // $NON-NLS-1$
@@ -125,6 +131,8 @@ public class JMSSamplerGui extends Abstr
         element.setUseReqMsgIdAsCorrelId(useReqMsgIdAsCorrelId.isSelected());
         element.setUseResMsgIdAsCorrelId(useResMsgIdAsCorrelId.isSelected());
         element.setTimeout(timeout.getText());
+        element.setExpiration(expiration.getText());
+        element.setPriority(priority.getText());
         element.setJMSSelector(jmsSelector.getText());
         element.setContent(messageContent.getText());
 
@@ -173,6 +181,8 @@ public class JMSSamplerGui extends Abstr
         useResMsgIdAsCorrelId.setSelected(sampler.isUseResMsgIdAsCorrelId());
 
         timeout.setText(sampler.getTimeout());
+        expiration.setText(sampler.getExpiration());
+        priority.setText(sampler.getPriority());
         jmsSelector.setText(sampler.getJMSSelector());
         messageContent.setInitialText(sampler.getContent());
         initialContextFactory.setText(sampler.getInitialContextFactory());
@@ -238,6 +248,8 @@ public class JMSSamplerGui extends Abstr
 
         JPanel timeoutPanel = new HorizontalPanel();
         timeoutPanel.add(timeout);
+        timeoutPanel.add(expiration);
+        timeoutPanel.add(priority);
         timeoutPanel.add(useNonPersistentDelivery);
         messageNorthPanel.add(timeoutPanel, BorderLayout.SOUTH);
 

Modified: jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/FixedQueueExecutor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/FixedQueueExecutor.java?rev=1607183&r1=1607182&r2=1607183&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/FixedQueueExecutor.java
(original)
+++ jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/FixedQueueExecutor.java
Tue Jul  1 20:54:07 2014
@@ -33,8 +33,6 @@ import org.apache.log.Logger;
  *
  * Used by JMS Sampler (Point to Point)
  *
- * Created on: October 28, 2004
- *
  */
 public class FixedQueueExecutor implements QueueExecutor {
 
@@ -68,7 +66,10 @@ public class FixedQueueExecutor implemen
      * {@inheritDoc}
      */
     @Override
-    public Message sendAndReceive(Message request) throws JMSException {
+    public Message sendAndReceive(Message request, 
+            int deliveryMode, 
+            int priority, 
+            long expiration) throws JMSException {
         String id = request.getJMSCorrelationID();
         if(id == null && !useReqMsgIdAsCorrelId){
             throw new IllegalArgumentException("Correlation id is null. Set the JMSCorrelationID
header.");
@@ -78,13 +79,13 @@ public class FixedQueueExecutor implemen
         if(useReqMsgIdAsCorrelId) {// msgId not available until after send() is called
             // Note: there is only one admin object which is shared between all threads
             synchronized (admin) {// interlock with Receiver
-                producer.send(request);
+                producer.send(request, deliveryMode, priority, expiration);
                 id=request.getJMSMessageID();
                 admin.putRequest(id, request, countDownLatch);
             }
         } else {
             admin.putRequest(id, request, countDownLatch);            
-            producer.send(request);
+            producer.send(request, deliveryMode, priority, expiration);
         }
 
         try {

Modified: jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java?rev=1607183&r1=1607182&r2=1607183&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java (original)
+++ jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java Tue
Jul  1 20:54:07 2014
@@ -70,6 +70,10 @@ public class JMSSampler extends Abstract
 
     private static final String TIMEOUT = "JMSSampler.timeout"; // $NON-NLS-1$
 
+    private static final String JMS_PRIORITY = "JMSSampler.priority"; // $NON-NLS-1$
+
+    private static final String JMS_EXPIRATION = "JMSSampler.expiration"; // $NON-NLS-1$
+
     private static final String JMS_SELECTOR = "JMSSampler.jmsSelector"; // $NON-NLS-1$
 
     private static final String JMS_SELECTOR_DEFAULT = ""; // $NON-NLS-1$
@@ -138,7 +142,10 @@ public class JMSSampler extends Abstract
         try {
             TextMessage msg = createMessage();
             if (isOneway()) {
-                producer.send(msg);
+                int deliveryMode = isNonPersistent() ? 
+                        DeliveryMode.NON_PERSISTENT:DeliveryMode.PERSISTENT;
+                producer.send(msg, deliveryMode, Integer.parseInt(getPriority()), 
+                        Long.parseLong(getExpiration()));
                 res.setRequestHeaders(Utils.messageProperties(msg));
                 res.setResponseOK();
                 res.setResponseData("Oneway request has no response data", null);
@@ -146,8 +153,10 @@ public class JMSSampler extends Abstract
                 if (!useTemporyQueue()) {
                     msg.setJMSReplyTo(receiveQueue);
                 }
-
-                Message replyMsg = executor.sendAndReceive(msg);
+                Message replyMsg = executor.sendAndReceive(msg,
+                        isNonPersistent() ? DeliveryMode.NON_PERSISTENT : DeliveryMode.PERSISTENT,

+                        Integer.parseInt(getPriority()), 
+                        Long.parseLong(getExpiration()));
                 res.setRequestHeaders(Utils.messageProperties(msg));
                 if (replyMsg == null) {
                     res.setResponseMessage("No reply message received");
@@ -351,20 +360,19 @@ public class JMSSampler extends Abstract
                 LOGGER.debug("Session created");
             }
 
-            if (getPropertyAsBoolean(IS_ONE_WAY)) {
+            if (isOneway()) {
                 producer = session.createSender(sendQueue);
                 if (isNonPersistent()) {
                     producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
                 }
+                producer.setPriority(Integer.parseInt(getPriority()));
+                producer.setTimeToLive(Long.parseLong(getExpiration()));
             } else {
 
                 if (useTemporyQueue()) {
                     executor = new TemporaryQueueExecutor(session, sendQueue);
                 } else {
                     producer = session.createSender(sendQueue);
-                    if (isNonPersistent()) {
-                        producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-                    }
                     executor = new FixedQueueExecutor(producer, getTimeoutAsInt(), isUseReqMsgIdAsCorrelId());
                 }
             }
@@ -466,7 +474,15 @@ public class JMSSampler extends Abstract
     public String getTimeout() {
         return getPropertyAsString(TIMEOUT, DEFAULT_TIMEOUT_STRING);
     }
+    
+    public String getExpiration() {
+        return getPropertyAsString(JMS_EXPIRATION, Long.toString(Utils.DEFAULT_NO_EXPIRY));
+    }
 
+    public String getPriority() {
+        return getPropertyAsString(JMS_PRIORITY, Integer.toString(Utils.DEFAULT_PRIORITY_4));
+    }
+    
     /**
      * {@inheritDoc}
      */
@@ -497,6 +513,14 @@ public class JMSSampler extends Abstract
     public void setTimeout(String s) {
         setProperty(JMSSampler.TIMEOUT, s);
     }
+    
+    public void setPriority(String s) {
+        setProperty(JMSSampler.JMS_PRIORITY, s, Integer.toString(Utils.DEFAULT_PRIORITY_4));
+    }
+    
+    public void setExpiration(String s) {
+        setProperty(JMSSampler.JMS_EXPIRATION, s, Long.toString(Utils.DEFAULT_NO_EXPIRY));
+    }
 
     /**
      * @return String JMS Selector

Modified: jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/PublisherSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/PublisherSampler.java?rev=1607183&r1=1607182&r2=1607183&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/PublisherSampler.java
(original)
+++ jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/PublisherSampler.java
Tue Jul  1 20:54:07 2014
@@ -27,6 +27,7 @@ import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.jms.DeliveryMode;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.naming.NamingException;
@@ -74,6 +75,10 @@ public class PublisherSampler extends Ba
     
     private static final String JMS_PROPERTIES = "jms.jmsProperties"; // $NON-NLS-1$
 
+    private static final String JMS_PRIORITY = "jms.priority"; // $NON-NLS-1$
+
+    private static final String JMS_EXPIRATION = "jms.expiration"; // $NON-NLS-1$
+
     //--
 
     // Does not need to be synch. because it is only accessed from the sampler thread
@@ -132,7 +137,7 @@ public class PublisherSampler extends Ba
     private void initClient() throws JMSException, NamingException {
         publisher = new Publisher(getUseJNDIPropertiesAsBoolean(), getJNDIInitialContextFactory(),

                 getProviderUrl(), getConnectionFactory(), getDestination(), isUseAuth(),
getUsername(),
-                getPassword(), isDestinationStatic(), getUseNonPersistentDelivery());
+                getPassword(), isDestinationStatic());
         ClientPool.addClient(publisher);
         log.debug("PublisherSampler.initClient called");
     }
@@ -168,23 +173,27 @@ public class PublisherSampler extends Ba
         
         try {
             Map<String, Object> msgProperties = getJMSProperties().getJmsPropertysAsMap();
+            int deliveryMode = getUseNonPersistentDelivery() ? DeliveryMode.NON_PERSISTENT
: DeliveryMode.PERSISTENT; 
+            int priority = Integer.parseInt(getPriority());
+            long expiration = Long.parseLong(getExpiration());
+            
             for (int idx = 0; idx < loop; idx++) {
                 if (JMSPublisherGui.TEXT_MSG_RSC.equals(type)){
                     String tmsg = getMessageContent();
-                    Message msg = publisher.publish(tmsg, getDestination(), msgProperties);
+                    Message msg = publisher.publish(tmsg, getDestination(), msgProperties,
deliveryMode, priority, expiration);
                     buffer.append(tmsg);
                     Utils.messageProperties(propBuffer, msg);
                 } else if (JMSPublisherGui.MAP_MSG_RSC.equals(type)){
                     Map<String, Object> m = getMapContent();
-                    Message msg = publisher.publish(m, getDestination(), msgProperties);
+                    Message msg = publisher.publish(m, getDestination(), msgProperties, deliveryMode,
priority, expiration);
                     Utils.messageProperties(propBuffer, msg);
                 } else if (JMSPublisherGui.OBJECT_MSG_RSC.equals(type)){
                     Serializable omsg = getObjectContent();
-                    Message msg = publisher.publish(omsg, getDestination(), msgProperties);
+                    Message msg = publisher.publish(omsg, getDestination(), msgProperties,
deliveryMode, priority, expiration);
                     Utils.messageProperties(propBuffer, msg);
                 } else if (JMSPublisherGui.BYTES_MSG_RSC.equals(type)){
                     byte[] bmsg = getBytesContent();
-                    Message msg = publisher.publish(bmsg, getDestination(), msgProperties);
+                    Message msg = publisher.publish(bmsg, getDestination(), msgProperties,
deliveryMode, priority, expiration);
                     Utils.messageProperties(propBuffer, msg);
                 } else {
                     throw new JMSException(type+ " is not recognised");                 
  
@@ -490,6 +499,22 @@ public class PublisherSampler extends Ba
         return getPropertyAsString(TEXT_MSG);
     }
 
+    public String getExpiration() {
+        return getPropertyAsString(JMS_EXPIRATION, Long.toString(Utils.DEFAULT_NO_EXPIRY));
+    }
+
+    public String getPriority() {
+        return getPropertyAsString(JMS_PRIORITY, Integer.toString(Utils.DEFAULT_PRIORITY_4));
+    }
+    
+    public void setPriority(String s) {
+        setProperty(JMS_PRIORITY, s, Integer.toString(Utils.DEFAULT_PRIORITY_4));
+    }
+    
+    public void setExpiration(String s) {
+        setProperty(JMS_EXPIRATION, s, Long.toString(Utils.DEFAULT_NO_EXPIRY));
+    }
+    
     /**
      * @param value boolean use NON_PERSISTENT
      */

Modified: jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/QueueExecutor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/QueueExecutor.java?rev=1607183&r1=1607182&r2=1607183&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/QueueExecutor.java
(original)
+++ jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/QueueExecutor.java
Tue Jul  1 20:54:07 2014
@@ -30,13 +30,18 @@ import javax.jms.Message;
 public interface QueueExecutor {
     /**
      * Sends and receives a message.
-     *
-     * @param request
-     *            the message to send
+     * 
+     * @param request the message to send
+     * @param deliveryMode
+     * @param priority
+     * @param expiration
      * @return the received message or <code>null</code>
      * @throws JMSException
      *             in case of an exception from the messaging system
      */
-    Message sendAndReceive(Message request) throws JMSException;
+    Message sendAndReceive(Message request,
+            int deliveryMode, 
+            int priority, 
+            long expiration) throws JMSException;
 
 }

Modified: jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/TemporaryQueueExecutor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/TemporaryQueueExecutor.java?rev=1607183&r1=1607182&r2=1607183&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/TemporaryQueueExecutor.java
(original)
+++ jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/TemporaryQueueExecutor.java
Tue Jul  1 20:54:07 2014
@@ -28,10 +28,6 @@ import javax.jms.QueueSession;
  * Request/reply executor with a temporary reply queue. <br>
  * 
  * Used by JMS Sampler (Point to Point)
- * 
- * Created on: October 28, 2004
- *
- * @version $Revision$
  */
 public class TemporaryQueueExecutor implements QueueExecutor {
     /** The sender and receiver. */
@@ -54,7 +50,10 @@ public class TemporaryQueueExecutor impl
      * {@inheritDoc}
      */
     @Override
-    public Message sendAndReceive(Message request) throws JMSException {
+    public Message sendAndReceive(Message request, 
+            int deliveryMode, 
+            int priority, 
+            long expiration) throws JMSException {
         return requestor.request(request);
     }
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1607183&r1=1607182&r2=1607183&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Tue Jul  1 20:54:07 2014
@@ -191,6 +191,7 @@ A workaround is to use a Java 7 update 4
 <li><bugzilla>56033</bugzilla> - Add Connection timeout and Read timeout
to SMTP Sampler</li>
 <li><bugzilla>56429</bugzilla> - MailReaderSampler - no need to fetch all
Messages if not all wanted</li>
 <li><bugzilla>56427</bugzilla> - MailReaderSampler enhancement: read message
header only</li>
+<li><bugzilla>56510</bugzilla> - JMS Publisher/Point to Point: Add JMSPriority
and JMSExpiration</li>
 </ul>
 
 <h3>Controllers</h3>



Mime
View raw message