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/04/26 23:29:00 UTC

svn commit: r938247 - in /jakarta/jmeter/trunk: src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/ xdocs/

Author: sebb
Date: Mon Apr 26 21:29:00 2010
New Revision: 938247

URL: http://svn.apache.org/viewvc?rev=938247&view=rev
Log:
Bug 49111 - "Message With ID Not Found" Error on JMS P2P sampler.
Fixed rest of bug

Modified:
    jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/FixedQueueExecutor.java
    jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java
    jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/Receiver.java
    jakarta/jmeter/trunk/xdocs/changes.xml

Modified: jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/FixedQueueExecutor.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/FixedQueueExecutor.java?rev=938247&r1=938246&r2=938247&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/FixedQueueExecutor.java (original)
+++ jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/FixedQueueExecutor.java Mon Apr 26 21:29:00 2010
@@ -52,20 +52,6 @@ public class FixedQueueExecutor implemen
      *            the queue to send the message on
      * @param timeout
      *            timeout to use for the return message
-     */
-    public FixedQueueExecutor(QueueSender producer, int timeout) {
-        this.producer = producer;
-        this.timeout = timeout;
-        this.useReqMsgIdAsCorrelId = false;
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param producer
-     *            the queue to send the message on
-     * @param timeout
-     *            timeout to use for the return message
      * @param useReqMsgIdAsCorrelId
      *            whether to use the request message id as the correlation id
      */
@@ -85,12 +71,16 @@ public class FixedQueueExecutor implemen
             return null;
         }
 
+        final MessageAdmin admin = MessageAdmin.getAdmin();
         if(useReqMsgIdAsCorrelId) {// msgId not available until after send() is called
-            producer.send(request); // TODO - fix timing bug see Bugzilla 49111
-            id=request.getJMSMessageID();
-            MessageAdmin.getAdmin().putRequest(id, request);            
+            // Note: there is only one admin object which is shared between all threads
+            synchronized (admin) {// interlock with Receiver
+                producer.send(request);
+                id=request.getJMSMessageID();
+                admin.putRequest(id, request);
+            }
         } else {
-            MessageAdmin.getAdmin().putRequest(id, request);            
+            admin.putRequest(id, request);            
             producer.send(request);
         }
 
@@ -108,6 +98,6 @@ public class FixedQueueExecutor implemen
         } catch (InterruptedException e) {
             log.warn("Interrupt exception caught", e);
         }
-        return MessageAdmin.getAdmin().get(id);
+        return admin.get(id);
     }
 }
\ No newline at end of file

Modified: jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java?rev=938247&r1=938246&r2=938247&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java (original)
+++ jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java Mon Apr 26 21:29:00 2010
@@ -310,7 +310,8 @@ public class JMSSampler extends Abstract
             sendQueue = queue;
             if (!useTemporyQueue()) {
                 receiveQueue = (Queue) context.lookup(getReceiveQueue());
-                receiverThread = Receiver.createReceiver(factory, receiveQueue, getPrincipal(context), getCredentials(context));
+                receiverThread = Receiver.createReceiver(factory, receiveQueue, getPrincipal(context), getCredentials(context)
+                        , isUseReqMsgIdAsCorrelId());
             }
 
             String principal = null;

Modified: jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/Receiver.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/Receiver.java?rev=938247&r1=938246&r2=938247&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/Receiver.java (original)
+++ jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/Receiver.java Mon Apr 26 21:29:00 2010
@@ -38,9 +38,9 @@ public class Receiver implements Runnabl
 
     private final QueueConnection conn;
 
-    // private static Receiver receiver;
+    private final boolean useReqMsgIdAsCorrelId;
 
-    private Receiver(QueueConnectionFactory factory, Queue receiveQueue, String principal, String credentials) throws JMSException {
+    private Receiver(QueueConnectionFactory factory, Queue receiveQueue, String principal, String credentials, boolean useReqMsgIdAsCorrelId) throws JMSException {
         if (null != principal && null != credentials) {
             log.info("creating receiver WITH authorisation credentials");
             conn = factory.createQueueConnection(principal, credentials);
@@ -50,15 +50,16 @@ public class Receiver implements Runnabl
         }
         session = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
         consumer = session.createReceiver(receiveQueue);
+        this.useReqMsgIdAsCorrelId = useReqMsgIdAsCorrelId;
         log.debug("Receiver - ctor. Starting connection now");
         conn.start();
         log.info("Receiver - ctor. Connection to messaging system established");
     }
 
     public static Receiver createReceiver(QueueConnectionFactory factory, Queue receiveQueue,
-            String principal, String credentials)
+            String principal, String credentials, boolean useReqMsgIdAsCorrelId)
             throws JMSException {
-        Receiver receiver = new Receiver(factory, receiveQueue, principal, credentials);
+        Receiver receiver = new Receiver(factory, receiveQueue, principal, credentials, useReqMsgIdAsCorrelId);
         Thread thread = new Thread(receiver);
         thread.start();
         return receiver;
@@ -73,14 +74,20 @@ public class Receiver implements Runnabl
             try {
                 reply = consumer.receive(5000);
                 if (reply != null) {
-                    final String jmsCorrelationID = reply.getJMSCorrelationID();
-                    if (jmsCorrelationID == null) {
-                        log.warn("Received message with correlation id null. Discarding message ...");
+                    String messageKey;
+                    final MessageAdmin admin = MessageAdmin.getAdmin();
+                    if (useReqMsgIdAsCorrelId){
+                        messageKey = reply.getJMSMessageID();
+                        synchronized (admin) {// synchronize with FixedQueueExecutor
+                            admin.putReply(messageKey, reply);                            
+                        }
                     } else {
-                        if (log.isDebugEnabled()) {
-                            log.debug("Received message, correlation id:" + jmsCorrelationID);
+                        messageKey = reply.getJMSCorrelationID();
+                        if (messageKey == null) {// JMSMessageID cannot be null
+                            log.warn("Received message with correlation id null. Discarding message ...");
+                        } else {
+                            admin.putReply(messageKey, reply);
                         }
-                        MessageAdmin.getAdmin().putReply(reply.getJMSCorrelationID(), reply);
                     }
                 }
 

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=938247&r1=938246&r2=938247&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Mon Apr 26 21:29:00 2010
@@ -98,7 +98,7 @@ The XPath Assertion and XPath Extractor 
 <li>Bug 48573 - LDAPExtSampler directory context handling</li>
 <li>Bug 48579 - Single Bind does not show config information when LdapExt Sampler is accessed</li>
 <li>Bug 48747 - TCP Sampler swallows exceptions</li>
-<li>Bug 49111 - "Message With ID Not Found" Error on JMS P2P sampler. Partial fix (can still fail if "Use Request Message Id As Correlation Id" is selected)</li>
+<li>Bug 49111 - "Message With ID Not Found" Error on JMS P2P sampler.</li>
 </ul>
 
 <h3>Controllers</h3>