Madan Jampani | 890bc35 | 2014-10-01 22:35:29 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.store.messaging.impl; |
| 2 | |
| 3 | import java.util.concurrent.TimeUnit; |
| 4 | |
| 5 | import org.onlab.onos.store.cluster.impl.MessageSerializer; |
| 6 | import org.onlab.onos.store.messaging.Endpoint; |
| 7 | import org.onlab.onos.store.messaging.Response; |
| 8 | |
| 9 | public final class SimpleClient { |
| 10 | private SimpleClient() {} |
| 11 | |
| 12 | public static void main(String... args) throws Exception { |
| 13 | NettyMessagingService messaging = new TestNettyMessagingService(9081); |
| 14 | messaging.activate(); |
| 15 | |
| 16 | messaging.sendAsync(new Endpoint("localhost", 8080), "simple", "Hello World"); |
| 17 | Response<String> response = messaging.sendAndReceive(new Endpoint("localhost", 8080), "echo", "Hello World"); |
| 18 | System.out.println("Got back:" + response.get(2, TimeUnit.SECONDS)); |
| 19 | } |
| 20 | |
| 21 | public static class TestNettyMessagingService extends NettyMessagingService { |
| 22 | public TestNettyMessagingService(int port) throws Exception { |
| 23 | super(port); |
| 24 | MessageSerializer mgr = new MessageSerializer(); |
| 25 | mgr.activate(); |
| 26 | this.serializationService = mgr; |
| 27 | } |
| 28 | } |
| 29 | } |