This closes #27 JGroups Close Channel
This commit is contained in:
commit
9687c4003d
|
@ -18,6 +18,11 @@ package org.apache.activemq.artemis.api.core;
|
||||||
|
|
||||||
import org.jgroups.JChannel;
|
import org.jgroups.JChannel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An implementation of BroadcastEndpointFactory that uses an externally managed JChannel for JGroups clustering.
|
||||||
|
*
|
||||||
|
* Note - the underlying JChannel is not closed in this implementation.
|
||||||
|
*/
|
||||||
public class ChannelBroadcastEndpointFactory implements BroadcastEndpointFactory
|
public class ChannelBroadcastEndpointFactory implements BroadcastEndpointFactory
|
||||||
{
|
{
|
||||||
private final JChannel channel;
|
private final JChannel channel;
|
||||||
|
|
|
@ -126,6 +126,15 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint
|
||||||
channel.removeReceiver(receiver);
|
channel.removeReceiver(receiver);
|
||||||
clientOpened = false;
|
clientOpened = false;
|
||||||
}
|
}
|
||||||
|
internalCloseChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the channel used in this JGroups Broadcast.
|
||||||
|
* Can be overridden by implementations that use an externally managed channel.
|
||||||
|
*/
|
||||||
|
protected synchronized void internalCloseChannel()
|
||||||
|
{
|
||||||
channel.close();
|
channel.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,11 @@ package org.apache.activemq.artemis.api.core;
|
||||||
|
|
||||||
import org.jgroups.JChannel;
|
import org.jgroups.JChannel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An implementation of JGroupsBroadcastEndpoint that uses an externally managed JChannel for its operations.
|
||||||
|
*
|
||||||
|
* Note - this implementation does not close the JChannel, since its externally created.
|
||||||
|
*/
|
||||||
public class JGroupsChannelBroadcastEndpoint extends JGroupsBroadcastEndpoint
|
public class JGroupsChannelBroadcastEndpoint extends JGroupsBroadcastEndpoint
|
||||||
{
|
{
|
||||||
private final JChannel jChannel;
|
private final JChannel jChannel;
|
||||||
|
@ -33,4 +38,10 @@ public class JGroupsChannelBroadcastEndpoint extends JGroupsBroadcastEndpoint
|
||||||
{
|
{
|
||||||
return jChannel;
|
return jChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected synchronized void internalCloseChannel()
|
||||||
|
{
|
||||||
|
// no-op, this version takes an externally managed channel.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
import javax.jms.Queue;
|
import javax.jms.Queue;
|
||||||
|
|
||||||
|
import org.apache.activemq.artemis.api.core.BroadcastEndpoint;
|
||||||
import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory;
|
import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory;
|
||||||
import org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory;
|
import org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory;
|
||||||
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
|
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
|
||||||
|
@ -171,8 +172,14 @@ public class ConnectionFactoryWithJGroupsSerializationTest extends JMSTestBase
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
|
// small hack, the channel here is cached, so checking that it's not closed by any endpoint
|
||||||
|
BroadcastEndpoint broadcastEndpoint = jmsServer.getActiveMQServer().getConfiguration()
|
||||||
|
.getDiscoveryGroupConfigurations().get("dg1")
|
||||||
|
.getBroadcastEndpointFactory().createBroadcastEndpoint();
|
||||||
|
broadcastEndpoint.close(true);
|
||||||
if (channel != null)
|
if (channel != null)
|
||||||
{
|
{
|
||||||
|
assertFalse(channel.isClosed());
|
||||||
channel.close();
|
channel.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue