activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: NO-JIRA Add a close method to the session (cherry picked from commit 4c838c5fa3c83782b1bfaa069f2beb7a87a7beaa)
Date Thu, 20 Oct 2016 21:50:32 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.14.x 9b6b31ca2 -> 9363af6f3


NO-JIRA Add a close method to the session
(cherry picked from commit 4c838c5fa3c83782b1bfaa069f2beb7a87a7beaa)


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

Branch: refs/heads/activemq-5.14.x
Commit: 9363af6f37c9552bc2af71ba8782af00fce360cb
Parents: 9b6b31c
Author: Timothy Bish <tabish121@gmail.com>
Authored: Thu Oct 20 17:49:26 2016 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Thu Oct 20 17:50:25 2016 -0400

----------------------------------------------------------------------
 .../transport/amqp/client/AmqpSession.java      | 26 ++++++++++++++++++++
 1 file changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/9363af6f/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpSession.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpSession.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpSession.java
index 3804603..7cb745c 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpSession.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpSession.java
@@ -16,7 +16,9 @@
  */
 package org.apache.activemq.transport.amqp.client;
 
+import java.io.IOException;
 import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.activemq.transport.amqp.client.util.AsyncResult;
@@ -38,6 +40,7 @@ public class AmqpSession extends AmqpAbstractResource<Session> {
     private final AmqpConnection connection;
     private final String sessionId;
     private final AmqpTransactionContext txContext;
+    private final AtomicBoolean closed = new AtomicBoolean();
 
     /**
      * Create a new session instance.
@@ -54,6 +57,29 @@ public class AmqpSession extends AmqpAbstractResource<Session> {
     }
 
     /**
+     * Close the receiver, a closed receiver will throw exceptions if any further send
+     * calls are made.
+     *
+     * @throws IOException if an error occurs while closing the receiver.
+     */
+    public void close() throws IOException {
+        if (closed.compareAndSet(false, true)) {
+            final ClientFuture request = new ClientFuture();
+            getScheduler().execute(new Runnable() {
+
+                @Override
+                public void run() {
+                    checkClosed();
+                    close(request);
+                    pumpToProtonTransport(request);
+                }
+            });
+
+            request.sync();
+        }
+    }
+
+    /**
      * Create an anonymous sender.
      *
      * @return a newly created sender that is ready for use.


Mime
View raw message