当前位置: 首页>>代码示例>>Java>>正文


Java Client.stop方法代码示例

本文整理汇总了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);
        }
    }
 
开发者ID:advantageous,项目名称:qbit,代码行数:24,代码来源:RemoteFactoryUtil.java

示例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();
}
 
开发者ID:advantageous,项目名称:qbit,代码行数:27,代码来源:Bug746.java

示例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();

}
 
开发者ID:advantageous,项目名称:qbit,代码行数:33,代码来源:WebSocketProxy.java

示例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();

}
 
开发者ID:advantageous,项目名称:qbit,代码行数:32,代码来源:WebSocketProxy.java

示例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();


    }
 
开发者ID:advantageous,项目名称:qbit-extensions,代码行数:56,代码来源:SimpleRestServerWithURIParamsMain.java

示例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();

}
 
开发者ID:advantageous,项目名称:qbit,代码行数:49,代码来源:WebSocketProxy.java


注:本文中的io.advantageous.qbit.client.Client.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。