本文整理汇总了Java中io.advantageous.qbit.client.Client.stop方法的典型用法代码示例。如果您正苦于以下问题:Java Client.stop方法的具体用法?Java Client.stop怎么用?Java Client.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.advantageous.qbit.client.Client
的用法示例。
在下文中一共展示了Client.stop方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRemoteByName
import io.advantageous.qbit.client.Client; //导入方法依赖的package包/类
public static <T> T getRemoteByName(final URI address, final Class<T> clazz, final String name) {
/* Start QBit client for WebSocket calls. */
final Client client = ClientBuilder.clientBuilder()
.setHost(address.getHost())
.setPort(address.getPort())
.setUri(address.getPath())
.build();
try {
/* Create a proxy to the service. */
final T clientProxy = client.createProxy(clazz, name);
client.start();
return clientProxy;
} catch (Exception ex) {
try {
client.stop();
} catch (Exception ex2) {
//don't log, we are cleaning up.
}
/* Wrong place to handle the exception so just rethrow it. */
throw new IllegalStateException(ex);
}
}
示例2: testWithClient
import io.advantageous.qbit.client.Client; //导入方法依赖的package包/类
@Test //Works
public void testWithClient() {
int port = PortUtils.findOpenPortStartAt(9999);
final ServiceEndpointServer serviceEndpointServer =
EndpointServerBuilder.endpointServerBuilder().setPort(port)
.addService("foo", new FeedServiceImpl()).build().startServerAndWait();
final Client client = ClientBuilder.clientBuilder().setPort(port).build().startClient();
final FeedService feedService = client.createProxy(FeedService.class, "foo");
final List<FeedMeta> feedMetas = feedService.listFeeds().blockingGet(Duration.ofSeconds(30));
assertNotNull(feedMetas);
assertEquals(1, feedMetas.size());
assertEquals("Hello", feedMetas.get(0).name);
serviceEndpointServer.stop();
client.stop();
}
示例3: testDisconnect
import io.advantageous.qbit.client.Client; //导入方法依赖的package包/类
@Test
public void testDisconnect() {
final int port = PortUtils.findOpenPortStartAt(7777);
final ServiceEndpointServer serviceEndpointServer = EndpointServerBuilder.endpointServerBuilder()
.setPort(port).setHost("localhost")
.addService(new EmployeeServiceImpl()).build().startServerAndWait();
final Client client = ClientBuilder.clientBuilder().setPort(port).setHost("localhost").build().startClient();
final EmployeeServiceClient employeeService = client.createProxy(EmployeeServiceClient.class, "employeeserviceimpl");
Promise<Employee> promise = Promises.blockingPromise();
employeeService.addEmployee(new Employee("rick")).asHandler().invokeWithPromise(promise.asHandler());
ServiceProxyUtils.flushServiceProxy(employeeService);
assertTrue(promise.asHandler().success());
serviceEndpointServer.stop();
promise = Promises.blockingPromise();
employeeService.addEmployee(new Employee("rick")).asHandler().invokeWithPromise(promise.asHandler());
assertTrue(promise.asHandler().failure());
assertTrue(promise.asHandler().cause() instanceof ConnectException);
client.stop();
}
示例4: testSendGenericList
import io.advantageous.qbit.client.Client; //导入方法依赖的package包/类
@Test
public void testSendGenericList() {
final int port = PortUtils.findOpenPortStartAt(7777);
final ServiceEndpointServer serviceEndpointServer = EndpointServerBuilder.endpointServerBuilder()
.setPort(port).setHost("localhost")
.addService(new EmployeeServiceImpl()).build().startServerAndWait();
final Client client = ClientBuilder.clientBuilder().setPort(port).setHost("localhost").build().startClient();
final EmployeeServiceClient employeeService = client.createProxy(EmployeeServiceClient.class, "employeeserviceimpl");
Promise<Boolean> promise = Promises.blockingPromise();
employeeService.addEmployees(Arrays.asList(new Employee("rick"))).asHandler().invokeWithPromise(promise.asHandler());
ServiceProxyUtils.flushServiceProxy(employeeService);
boolean success = promise.asHandler().success();
if (!success) {
promise.asHandler().cause().printStackTrace();
}
assertTrue(success);
serviceEndpointServer.stop();
client.stop();
}
示例5: main
import io.advantageous.qbit.client.Client; //导入方法依赖的package包/类
public static void main(String... args) throws Exception {
QBitSystemManager systemManager = new QBitSystemManager();
/* Start Service server. */
final ServiceEndpointServer server = endpointServerBuilder()
.setSystemManager(systemManager)
.setPort(7000).build();
server.initServices(new AdderService());
server.start();
/* Start QBit client for WebSocket calls. */
final Client client = clientBuilder().setPort(7000).setProtocolBatchSize(1).build();
/* Create a proxy to the service. */
final AdderServiceClientInterface adderService =
client.createProxy(AdderServiceClientInterface.class, "adder-service");
client.start();
/* Call the service */
adderService.add(System.out::println, 1, 2);
HttpClient httpClient = httpClientBuilder()
.setHost("localhost")
.setPort(7000).build();
httpClient.startClient();
String results = httpClient
.get("/services/adder-service/add/2/2")
.body();
System.out.println(results);
// HttpTextResponse httpResponse = httpClient.get("/services/adder-service/foo/randomcrap/2");
// //System.out.println(httpResponse);
//
//
// httpResponse = httpClient.get("/services/adder-bs/foo/randomcrap/2");
// //System.out.println(httpResponse);
Sys.sleep(100);
client.stop();
httpClient.stop();
systemManager.shutDown();
}
示例6: testSendBoolean
import io.advantageous.qbit.client.Client; //导入方法依赖的package包/类
@Test
public void testSendBoolean() {
final int port = PortUtils.findOpenPortStartAt(7777);
final ServiceEndpointServer serviceEndpointServer = EndpointServerBuilder.endpointServerBuilder()
.setPort(port).setHost("localhost")
.addService(new EmployeeServiceImpl()).build().startServerAndWait();
final Client client = ClientBuilder.clientBuilder().setPort(port).setHost("localhost").build().startClient();
final EmployeeServiceClient employeeService = client.createProxy(EmployeeServiceClient.class, "employeeserviceimpl");
Promise<Boolean> promise = Promises.blockingPromise();
employeeService.sendBoolean(true).asHandler().invokeWithPromise(promise.asHandler());
ServiceProxyUtils.flushServiceProxy(employeeService);
boolean success = promise.asHandler().success();
if (!success) {
promise.asHandler().cause().printStackTrace();
}
assertTrue(success);
assertTrue(promise.asHandler().get());
Promise<Boolean> promise2 = Promises.blockingPromise();
employeeService.sendBoolean(false).asHandler().invokeWithPromise(promise2.asHandler());
ServiceProxyUtils.flushServiceProxy(employeeService);
boolean success2 = promise2.asHandler().success();
if (!success2) {
promise2.asHandler().cause().printStackTrace();
}
assertTrue(success2);
assertFalse(promise2.asHandler().get());
serviceEndpointServer.stop();
client.stop();
}