Forgot to provide that I'm using chronicle-engine 1.9.4
--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import net.openhft.chronicle.engine.server.ServerEndpoint;
import net.openhft.chronicle.engine.tree.VanillaAssetTree;
import net.openhft.chronicle.network.TCPRegistry;
import net.openhft.chronicle.network.connection.TcpChannelHub;
import net.openhft.chronicle.wire.WireType;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
/**
* @author Rob Austin.
*/
public class Test {
private static final String CONNECTION = "host.port.KeySubscriptionTest";
public static final WireType WIRE_TYPE = WireType.TEXT;
private VanillaAssetTree serverAssetTree;
@Before
public void before() throws IOException {
serverAssetTree = new VanillaAssetTree().forTesting();
TCPRegistry.createServerSocketChannelFor(CONNECTION);
new ServerEndpoint(CONNECTION, serverAssetTree, WIRE_TYPE);
}
/**
* run this with a profiler
* @throws InterruptedException
*/
@Test
public void test2() throws InterruptedException {
VanillaAssetTree clientTree = new VanillaAssetTree().forRemoteAccess(CONNECTION, WIRE_TYPE);
final TcpChannelHub hub = clientTree.root().findView(TcpChannelHub.class);
assert hub != null;
for (; ; ) {
Thread.sleep(2000); // give time for the disconnect and reconnect
hub.forceDisconnect();
}
}
}
package testing;
import net.openhft.chronicle.engine.api.map.MapView;
import net.openhft.chronicle.engine.api.pubsub.TopicSubscriber;
import net.openhft.chronicle.engine.server.ServerEndpoint;
import net.openhft.chronicle.engine.tree.VanillaAssetTree;
import net.openhft.chronicle.network.TCPRegistry;
import net.openhft.chronicle.network.connection.TcpChannelHub;
import net.openhft.chronicle.wire.WireType;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
public class EngineTest {
private static final String CONNECTION = "host.port.KeySubscriptionTest";
public static final WireType WIRE_TYPE = WireType.TEXT;
private VanillaAssetTree serverAssetTree;
private MapView<String, String> dataMap;
private boolean hasSubscriber = true;
@Before
public void before() throws IOException {
serverAssetTree = new VanillaAssetTree().forTesting();
dataMap = serverAssetTree.acquireMap("/data/chronicle", String.class, String.class);
TCPRegistry.createServerSocketChannelFor(CONNECTION);
new ServerEndpoint(CONNECTION, serverAssetTree, WIRE_TYPE);
}
@Test
public void test2() throws InterruptedException {
VanillaAssetTree clientTree = new VanillaAssetTree().forRemoteAccess(CONNECTION, WIRE_TYPE);
final TcpChannelHub hub = clientTree.root().findView(TcpChannelHub.class);
if(hasSubscriber) {
TopicSubscriber<String, String> topicSubscriber =
(topic, message) -> System.out.println("Topic " + topic + " message " + message);
clientTree.registerTopicSubscriber("/data/chronicle", String.class, String.class, topicSubscriber);
}
assert hub != null;
for (; ; ) {
if(hasSubscriber)
dataMap.put("TestKey", "TestValue");
Thread.sleep(2000); // give time for the disconnect and reconnect
hub.forceDisconnect();
}
}
}
<dependency>
<groupId>net.openhft</groupId>
<artifactId>chronicle-bom</artifactId>
<version>1.10.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
On 8 Nov 2015, at 11:41, Alex Smith <singapo...@gmail.com> wrote: