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


Java Client.start方法代码示例

本文整理汇总了Java中io.advantageous.qbit.client.Client.start方法的典型用法代码示例。如果您正苦于以下问题:Java Client.start方法的具体用法?Java Client.start怎么用?Java Client.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.advantageous.qbit.client.Client的用法示例。


在下文中一共展示了Client.start方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: addEventConnector

import io.advantageous.qbit.client.Client; //导入方法依赖的package包/类
private void addEventConnector(final String newHost, final int newPort) {

        if (info) logger.info(Str.sputs("Adding new event connector for",
                eventBusName, "host",
                newHost, "port", newPort));

        /* A client replicator */
        final EventBusReplicationClientBuilder clientReplicatorBuilder = eventBusReplicationClientBuilder();
        clientReplicatorBuilder.setName(this.eventBusName);
        clientReplicatorBuilder.clientBuilder().setPort(newPort).setHost(newHost);
        final Client client = clientReplicatorBuilder.build();
        final EventConnector eventConnector = clientReplicatorBuilder.build(client);
        client.start();
        eventConnectorHub.add(eventConnector);
    }
 
开发者ID:advantageous,项目名称:qbit-extensions,代码行数:16,代码来源:EventBusCluster.java

示例3: main

import io.advantageous.qbit.client.Client; //导入方法依赖的package包/类
public static void main(String... args) throws Exception {

        Client client = new ClientBuilder().setPort(9998)
                .setAutoFlush(true).setFlushInterval(50)
                .setProtocolBatchSize(50).build();

        PingService pingService = client.createProxy(PingService.class, "ping");

        client.start();

        pingService.ping(s -> puts("FROM SERVER", s));
    }
 
开发者ID:advantageous,项目名称:qbit,代码行数:13,代码来源:ServiceServerClient.java

示例4: main

import io.advantageous.qbit.client.Client; //导入方法依赖的package包/类
public static void main(String... args) {

        String host = "localhost";

        int port = 8080;


        /* Create a client object.
        * A client object connects to a ServiceEndpointServer so
        * you can invoke a service over WebSocket.
        */
        final Client client = new ClientBuilder()
                .setPort(port).setHost(host).setPollTime(10)
                .setAutoFlush(true).setFlushInterval(50)
                .setRequestBatchSize(50)
                .setProtocolBatchSize(50).build();

        client.start();

        final TodoServiceClientInterface todoService =
                client.createProxy(TodoServiceClientInterface.class, "todoService");



        todoService.add(new TodoItem("Buy Milk"));
        todoService.add(new TodoItem("Buy Hot dogs"));
        todoService.list(todoItems -> { //LAMBDA EXPRESSION Java 8

            for (TodoItem item : todoItems) {
                System.out.println("TODO ITEM " +
                        item.getDescription() + " " +
                        item.getName() + " " +
                        item.getDue());
            }
        });


        Sys.sleep(1000);


    }
 
开发者ID:advantageous,项目名称:qbit-extensions,代码行数:42,代码来源:TodoClientMain.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


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