Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set the number of connections? #11010

Open
zxrneu opened this issue Nov 24, 2022 · 4 comments
Open

How to set the number of connections? #11010

zxrneu opened this issue Nov 24, 2022 · 4 comments
Labels
component/sdk Related with apache/dubbo help wanted Everything needs help from contributors type/proposal Everything you want Dubbo have

Comments

@zxrneu
Copy link

zxrneu commented Nov 24, 2022

### Question:reference.setConnections(10);//设置未生效
image

There is only one connection. How do you make multiple connections

server

public class EchoServer {
    public static void main(String[] args) throws IOException {
        ServiceConfig<EchoService> service = new ServiceConfig<>();
        service.setInterface(EchoService.class);
        service.setRef(new EchoImpl());

        DubboBootstrap bootstrap = DubboBootstrap.getInstance();
        bootstrap.application(new ApplicationConfig("tri-stub-server"))
//               .registry(new RegistryConfig("multicast://127.0.0.1:2181"))
                .protocol(new ProtocolConfig(CommonConstants.TRIPLE, 3002))
                .service(service)
                .start();
        System.out.println("Dubbo triple stub server started");
        System.in.read();
    }
}

client

public class EchoClient {
    public static void main(String[] args) throws IOException {
        for (int i = 0; i < 3; i++) {
            new Thread(()->{
                DubboBootstrap bootstrap = DubboBootstrap.newInstance();
                System.out.println(bootstrap);
                ReferenceConfig<EchoService> ref = new ReferenceConfig<>();
                ref.setInterface(EchoService.class);
                ref.setProtocol(CommonConstants.TRIPLE);
                ref.setProxy(CommonConstants.NATIVE_STUB);
                ref.setTimeout(3000);
                ref.setUrl("tri://127.0.0.1:3002");
                ref.setConnections(10);//设置未生效
                bootstrap.application(new ApplicationConfig("tri-stub-client"))
                        .reference(ref)
                        .start();

                EchoService echoService = ref.get();
//                Scanner sc = new Scanner(System.in);
                while (true){
//                    String input = sc.next();
                    EchoRequest request = EchoRequest.newBuilder().setMessage("input").build();
                    EchoResponse echoResponse = echoService.echo(request);
                    System.out.println("Received reply:" + echoResponse.getMessage());
                }
            }).start();
        }
        System.in.read();

    }
}
@AlbumenJ AlbumenJ transferred this issue from apache/dubbo-samples Nov 24, 2022
@AlbumenJ
Copy link
Member

@EarthChen PTAL

@EarthChen
Copy link
Member

EarthChen commented Nov 29, 2022

triple protocol does not currently implement multiple connections, or connection pool. Will you help us get it done?

@zxrneu
Copy link
Author

zxrneu commented Nov 29, 2022

dubbo 下的grpc协议是不是也不支持多连接?

@AlbumenJ
Copy link
Member

dubbo 下的grpc协议是不是也不支持多连接?

Yep

@wxbty wxbty added help wanted Everything needs help from contributors type/proposal Everything you want Dubbo have component/sdk Related with apache/dubbo labels Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/sdk Related with apache/dubbo help wanted Everything needs help from contributors type/proposal Everything you want Dubbo have
Projects
None yet
Development

No branches or pull requests

4 participants