本文整理汇总了Java中com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeServer.close方法的典型用法代码示例。如果您正苦于以下问题:Java HeaderExchangeServer.close方法的具体用法?Java HeaderExchangeServer.close怎么用?Java HeaderExchangeServer.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeServer
的用法示例。
在下文中一共展示了HeaderExchangeServer.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeServer; //导入方法依赖的package包/类
public static void main( String[] args ) throws Exception {
final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler( handler );
Thread serverThread = new Thread( new Runnable() {
public void run() {
try {
exchangeServer = new HeaderExchangeServer(
Transporters.bind(
clientUrl.addParameter( Constants.HEARTBEAT_KEY, 1000 ),
serverHandler ) );
serverStarted = true;
} catch ( Exception e ) {
e.printStackTrace();
}
}
} );
serverThread.setDaemon( true );
serverThread.start();
while ( !serverStarted ) {
Thread.sleep( 1000 );
}
HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler( handler );
ExchangeClient exchangeClient = new HeaderExchangeClient(
Transporters.connect( clientUrl, clientHandler ) );
for ( int i = 0; i < 10; i++ ) {
Thread.sleep( 1000 );
System.out.print( "." );
}
System.out.println();
if ( clientHandler.getHeartBeatCount() > 0 ) {
System.out.printf( "Client receives %d heartbeats",
clientHandler.getHeartBeatCount() );
} else {
throw new Exception( "Server heartbeat does not work." );
}
exchangeClient.close();
exchangeServer.close();
}
示例2: main
import com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeServer; //导入方法依赖的package包/类
public static void main( String[] args ) throws Exception {
final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler( handler );
Thread serverThread = new Thread( new Runnable() {
public void run() {
try {
exchangeServer = new HeaderExchangeServer(
Transporters.bind( serverUrl, serverHandler ) );
serverStarted = true;
} catch ( Exception e ) {
e.printStackTrace();
}
}
} );
serverThread.setDaemon( true );
serverThread.start();
while ( ! serverStarted ) {
Thread.sleep( 1000 );
}
URL url = serverUrl.addParameter( Constants.HEARTBEAT_KEY, 1000 );
HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler( handler );
ExchangeClient exchangeClient = new HeaderExchangeClient(
Transporters.connect( url, clientHandler ) );
for( int i = 0; i < 10; i++ ) {
Thread.sleep( 1000 );
System.out.print( "." );
}
System.out.println();
if ( serverHandler.getHeartBeatCount() > 0 ) {
System.out.printf( "Server receives %d heartbeats",
serverHandler.getHeartBeatCount() );
} else {
throw new Exception( "Client heartbeat does not work." );
}
exchangeClient.close();
exchangeServer.close();
}
示例3: main
import com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeServer; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler(handler);
Thread serverThread = new Thread(new Runnable() {
public void run() {
try {
exchangeServer = new HeaderExchangeServer(
Transporters.bind(
clientUrl.addParameter(Constants.HEARTBEAT_KEY, 1000),
serverHandler));
serverStarted = true;
} catch (Exception e) {
e.printStackTrace();
}
}
});
serverThread.setDaemon(true);
serverThread.start();
while (!serverStarted) {
Thread.sleep(1000);
}
HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler(handler);
ExchangeClient exchangeClient = new HeaderExchangeClient(Transporters.connect(clientUrl, clientHandler),true);
for (int i = 0; i < 10; i++) {
Thread.sleep(1000);
System.out.print(".");
}
System.out.println();
if (clientHandler.getHeartBeatCount() > 0) {
System.out.printf("Client receives %d heartbeats",
clientHandler.getHeartBeatCount());
} else {
throw new Exception("Server heartbeat does not work.");
}
exchangeClient.close();
exchangeServer.close();
}
示例4: main
import com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeServer; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler(handler);
Thread serverThread = new Thread(new Runnable() {
public void run() {
try {
exchangeServer = new HeaderExchangeServer(
Transporters.bind(serverUrl, serverHandler));
serverStarted = true;
} catch (Exception e) {
e.printStackTrace();
}
}
});
serverThread.setDaemon(true);
serverThread.start();
while (!serverStarted) {
Thread.sleep(1000);
}
URL url = serverUrl.addParameter(Constants.HEARTBEAT_KEY, 1000);
HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler(handler);
ExchangeClient exchangeClient = new HeaderExchangeClient(Transporters.connect(url, clientHandler),true);
for (int i = 0; i < 10; i++) {
Thread.sleep(1000);
System.out.print(".");
}
System.out.println();
if (serverHandler.getHeartBeatCount() > 0) {
System.out.printf("Server receives %d heartbeats",
serverHandler.getHeartBeatCount());
} else {
throw new Exception("Client heartbeat does not work.");
}
exchangeClient.close();
exchangeServer.close();
}