activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject activemq-artemis git commit: idea
Date Fri, 04 Mar 2016 22:42:26 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 8cbcc809a -> bbf206214


idea


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

Branch: refs/heads/master
Commit: bbf206214a7564edb7d3aca5fac63fa7467bc06e
Parents: 8cbcc80
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Fri Mar 4 13:21:33 2016 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Fri Mar 4 13:21:33 2016 -0500

----------------------------------------------------------------------
 .../core/impl/ActiveMQSessionContext.java       | 34 ++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bbf20621/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
index f723802..029edd1 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
@@ -24,7 +24,9 @@ import java.security.PrivilegedAction;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
@@ -99,6 +101,7 @@ import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
 import org.apache.activemq.artemis.spi.core.remoting.SessionContext;
+import org.apache.activemq.artemis.utils.ReusableLatch;
 import org.apache.activemq.artemis.utils.TokenBucketLimiterImpl;
 import org.apache.activemq.artemis.utils.VersionLoader;
 
@@ -647,9 +650,28 @@ public class ActiveMQSessionContext extends SessionContext {
          sendPacketWithoutLock(sessionChannel, createQueueRequest);
       }
 
-      SessionCreateConsumerMessage createConsumerRequest = new SessionCreateConsumerMessage(getConsumerID(consumerInternal),
consumerInternal.getQueueName(), consumerInternal.getFilterString(), consumerInternal.isBrowseOnly(),
false);
+      ChannelHandler originalHandler = sessionChannel.getHandler();
+      FailoverHandler failoverHandler = new FailoverHandler();
 
-      sendPacketWithoutLock(sessionChannel, createConsumerRequest);
+      failoverHandler.latch.countUp();
+
+      sessionChannel.setHandler(failoverHandler);
+
+      try {
+
+         SessionCreateConsumerMessage createConsumerRequest = new SessionCreateConsumerMessage(getConsumerID(consumerInternal),
consumerInternal.getQueueName(), consumerInternal.getFilterString(), consumerInternal.isBrowseOnly(),
true);
+
+         sendPacketWithoutLock(sessionChannel, createConsumerRequest);
+
+         failoverHandler.latch.await(1, TimeUnit.SECONDS);
+      }
+      catch (Exception e) {
+         // Remove me.. just to compile the idea
+         e.printStackTrace();
+      }
+      finally {
+         sessionChannel.setHandler(originalHandler);
+      }
 
       int clientWindowSize = consumerInternal.getClientWindowSize();
 
@@ -734,6 +756,14 @@ public class ActiveMQSessionContext extends SessionContext {
       handleReceiveProducerFailCredits(message.getAddress(), message.getCredits());
    }
 
+   class FailoverHandler implements ChannelHandler {
+
+      public ReusableLatch latch = new ReusableLatch(0);
+      @Override
+      public void handlePacket(Packet packet) {
+         new Exception("Handler here " + packet).printStackTrace();
+      }
+   }
    class ClientSessionPacketHandler implements ChannelHandler {
 
       @Override


Mime
View raw message