ARTEMIS-1056 Better event processing

Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/dce59d54
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/dce59d54
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/dce59d54

Branch: refs/heads/master
Commit: dce59d5436bb4456c20cf4bf9179be83cd5de8c8
Parents: feadb63
Author: Clebert Suconic <[email protected]>
Authored: Mon Mar 27 17:45:01 2017 -0400
Committer: Justin Bertram <[email protected]>
Committed: Mon Mar 27 22:01:36 2017 -0500

----------------------------------------------------------------------
 .../amqp/proton/handler/ProtonHandler.java      | 41 ++++++++------------
 1 file changed, 16 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dce59d54/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
----------------------------------------------------------------------
diff --git 
a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
 
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
index 045016a..b5594fa 100644
--- 
a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
+++ 
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
@@ -164,7 +164,7 @@ public class ProtonHandler extends ProtonInitializable {
                      capacity = transport.capacity();
                   }
                } catch (Throwable e) {
-                  log.debug(e.getMessage(), e);
+                  log.warn(e.getMessage(), e);
                }
 
                receivedFirstPacket = true;
@@ -296,20 +296,6 @@ public class ProtonHandler extends ProtonInitializable {
       }
    }
 
-   private Event popEvent() {
-      synchronized (lock) {
-         Event ev = collector.peek();
-         if (ev != null) {
-            // pop will invalidate the event
-            // for that reason we make a new one
-            // Events are reused inside the collector, so we need to make a 
new one here
-            ev = ev.copy();
-            collector.pop();
-         }
-         return ev;
-      }
-   }
-
    private void dispatchAuth(boolean sasl) {
       for (EventHandler h : handlers) {
          h.onAuthInit(this, getConnection(), sasl);
@@ -322,17 +308,22 @@ public class ProtonHandler extends ProtonInitializable {
       // because we could have a distributed deadlock
       // while processing events (for instance onTransport)
       // while a client is also trying to write here
-      while ((ev = popEvent()) != null) {
-         for (EventHandler h : handlers) {
-            if (log.isTraceEnabled()) {
-               log.trace("Handling " + ev + " towards " + h);
-            }
-            try {
-               Events.dispatch(ev, h);
-            } catch (Exception e) {
-               log.warn(e.getMessage(), e);
-               connection.setCondition(new ErrorCondition());
+
+      synchronized (lock) {
+         while ((ev = collector.peek()) != null) {
+            for (EventHandler h : handlers) {
+               if (log.isTraceEnabled()) {
+                  log.trace("Handling " + ev + " towards " + h);
+               }
+               try {
+                  Events.dispatch(ev, h);
+               } catch (Exception e) {
+                  log.warn(e.getMessage(), e);
+                  connection.setCondition(new ErrorCondition());
+               }
             }
+
+            collector.pop();
          }
       }
 

Reply via email to