activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martyntay...@apache.org
Subject [1/3] activemq-artemis git commit: ARTEMIS-281 - add channel receiver correctly/
Date Wed, 25 Nov 2015 11:28:17 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master db0419259 -> 686e645c3


ARTEMIS-281 - add channel receiver correctly/

We also need to add the receiver whn the refcount = 1 and the channel may already be connected.

https://issues.apache.org/jira/browse/ARTEMIS-281


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

Branch: refs/heads/master
Commit: 00cac50a3710f487d2f91f5a0a3e64f12efd8ead
Parents: b34ee87
Author: Andy Taylor <andy.tayls67@gmail.com>
Authored: Tue Nov 24 10:51:28 2015 +0000
Committer: Andy Taylor <andy.tayls67@gmail.com>
Committed: Wed Nov 25 09:45:39 2015 +0000

----------------------------------------------------------------------
 .../api/core/JGroupsBroadcastEndpoint.java      | 26 +++++++++++---------
 1 file changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/00cac50a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java
index b75531e..e4b1519 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java
@@ -160,6 +160,19 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint
{
          this.refCount = 1;
          this.channelName = channelName;
          this.channel = channel;
+
+         //we always add this for the first ref count
+         channel.setReceiver(new ReceiverAdapter() {
+
+            @Override
+            public void receive(org.jgroups.Message msg) {
+               synchronized (receivers) {
+                  for (JGroupsReceiver r : receivers) {
+                     r.receive(msg);
+                  }
+               }
+            }
+         });
       }
 
       public synchronized void close(boolean closeWrappedChannel) {
@@ -171,6 +184,8 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint
{
             else {
                JChannelManager.removeChannel(this.channelName);
             }
+            //we always remove the receiver as its no longer needed
+            channel.setReceiver(null);
          }
       }
 
@@ -183,17 +198,6 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint
{
       public synchronized void connect() throws Exception {
          if (channel.isConnected())
             return;
-         channel.setReceiver(new ReceiverAdapter() {
-
-            @Override
-            public void receive(org.jgroups.Message msg) {
-               synchronized (receivers) {
-                  for (JGroupsReceiver r : receivers) {
-                     r.receive(msg);
-                  }
-               }
-            }
-         });
          channel.connect(channelName);
       }
 


Mime
View raw message