You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/06/27 16:44:49 UTC

[1/2] activemq-artemis git commit: ARTEMIS-1258 - Add ServerSession as an argument to beforeSend and afterSend

Repository: activemq-artemis
Updated Branches:
  refs/heads/master 437232b50 -> 12e746528


ARTEMIS-1258 - Add ServerSession as an argument to beforeSend and
afterSend


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

Branch: refs/heads/master
Commit: a538b969c097cf6f9c95c77707087578a2b48910
Parents: 437232b
Author: Christopher L. Shannon (cshannon) <ch...@gmail.com>
Authored: Tue Jun 27 08:02:47 2017 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Jun 27 12:42:40 2017 -0400

----------------------------------------------------------------------
 .../core/server/impl/ServerSessionImpl.java     | 17 ++++-----
 .../server/plugin/ActiveMQServerPlugin.java     | 37 ++++++++++++++++++++
 .../plugin/MethodCalledVerifier.java            |  6 ++--
 3 files changed, 50 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a538b969/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
index 83ff648..8e557d3 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
@@ -16,10 +16,8 @@
  */
 package org.apache.activemq.artemis.core.server.impl;
 
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObjectBuilder;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.Xid;
+import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -31,6 +29,11 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObjectBuilder;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.Xid;
+
 import org.apache.activemq.artemis.Closeable;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException;
@@ -89,8 +92,6 @@ import org.apache.activemq.artemis.utils.PrefixUtil;
 import org.apache.activemq.artemis.utils.collections.TypedProperties;
 import org.jboss.logging.Logger;
 
-import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe;
-
 /**
  * Server side Session implementation
  */
@@ -1300,7 +1301,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
                                           final boolean direct,
                                           boolean noAutoCreateQueue) throws Exception {
 
-      server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.beforeSend(tx, message, direct, noAutoCreateQueue) : null);
+      server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.beforeSend(this, tx, message, direct, noAutoCreateQueue) : null);
 
       // If the protocol doesn't support flow control, we have no choice other than fail the communication
       if (!this.getRemotingConnection().isSupportsFlowControl() && pagingManager.isDiskFull()) {
@@ -1351,7 +1352,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
       }
 
       final RoutingStatus finalResult = result;
-      server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.afterSend(tx, message, direct, noAutoCreateQueue, finalResult) : null);
+      server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.afterSend(this, tx, message, direct, noAutoCreateQueue, finalResult) : null);
 
       return result;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a538b969/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/ActiveMQServerPlugin.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/ActiveMQServerPlugin.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/ActiveMQServerPlugin.java
index dd304ae..770c429 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/ActiveMQServerPlugin.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/ActiveMQServerPlugin.java
@@ -228,11 +228,45 @@ public interface ActiveMQServerPlugin {
    /**
     * Before a message is sent
     *
+    * @param session the session that sends the message
     * @param tx
     * @param message
     * @param direct
     * @param noAutoCreateQueue
     */
+   default void beforeSend(ServerSession session, Transaction tx, Message message, boolean direct, boolean noAutoCreateQueue) {
+      //by default call the old method for backwards compatibility
+      this.beforeSend(tx, message, direct, noAutoCreateQueue);
+   }
+
+   /**
+    * After a message is sent
+    *
+    * @param session the session that sends the message
+    * @param tx
+    * @param message
+    * @param direct
+    * @param noAutoCreateQueue
+    * @param result
+    */
+   default void afterSend(ServerSession session, Transaction tx, Message message, boolean direct, boolean noAutoCreateQueue,
+         RoutingStatus result) {
+      //by default call the old method for backwards compatibility
+      this.afterSend(tx, message, direct, noAutoCreateQueue, result);
+   }
+
+
+   /**
+    * Before a message is sent
+    *
+    * @param tx
+    * @param message
+    * @param direct
+    * @param noAutoCreateQueue
+    *
+    * @deprecated use {@link #beforeSend(ServerSession, Transaction, Message, boolean, boolean)}
+    */
+   @Deprecated
    default void beforeSend(Transaction tx, Message message, boolean direct, boolean noAutoCreateQueue) {
 
    }
@@ -245,7 +279,10 @@ public interface ActiveMQServerPlugin {
     * @param direct
     * @param noAutoCreateQueue
     * @param result
+    *
+    * @deprecated use {@link #afterSend(ServerSession, Transaction, Message, boolean, boolean, RoutingStatus)}
     */
+   @Deprecated
    default void afterSend(Transaction tx, Message message, boolean direct, boolean noAutoCreateQueue,
          RoutingStatus result) {
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a538b969/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MethodCalledVerifier.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MethodCalledVerifier.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MethodCalledVerifier.java
index 71b01f1..493f7de 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MethodCalledVerifier.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MethodCalledVerifier.java
@@ -209,13 +209,15 @@ public class MethodCalledVerifier implements ActiveMQServerPlugin {
    }
 
    @Override
-   public void beforeSend(Transaction tx, Message message, boolean direct, boolean noAutoCreateQueue) {
+   public void beforeSend(ServerSession session, Transaction tx, Message message, boolean direct,
+         boolean noAutoCreateQueue) {
       Preconditions.checkNotNull(message);
       methodCalled(BEFORE_SEND);
    }
 
    @Override
-   public void afterSend(Transaction tx, Message message, boolean direct, boolean noAutoCreateQueue,
+   public void afterSend(ServerSession session, Transaction tx, Message message, boolean direct,
+         boolean noAutoCreateQueue,
                          RoutingStatus result) {
       Preconditions.checkNotNull(message);
       Preconditions.checkNotNull(result);


[2/2] activemq-artemis git commit: This closes #1373

Posted by cl...@apache.org.
This closes #1373


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

Branch: refs/heads/master
Commit: 12e7465283cf6580060a2e06fd18db4e0e71a354
Parents: 437232b a538b96
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Jun 27 12:42:41 2017 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Jun 27 12:42:41 2017 -0400

----------------------------------------------------------------------
 .../core/server/impl/ServerSessionImpl.java     | 17 ++++-----
 .../server/plugin/ActiveMQServerPlugin.java     | 37 ++++++++++++++++++++
 .../plugin/MethodCalledVerifier.java            |  6 ++--
 3 files changed, 50 insertions(+), 10 deletions(-)
----------------------------------------------------------------------