com.alibaba.dubbo.remoting.exchange.support.ExchangeHandlerAdapter Java Examples

The following examples show how to use com.alibaba.dubbo.remoting.exchange.support.ExchangeHandlerAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractBenchmarkServer.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
public void run(String[] args) throws Exception {
    if (args == null || args.length != 5) {
        throw new IllegalArgumentException(
                "must give three args: listenPort | maxThreads | responseSize | transporter | serialization");
    }
    int listenPort = Integer.parseInt(args[0]);
    int maxThreads = Integer.parseInt(args[1]);
    final int responseSize = Integer.parseInt(args[2]);
    String transporter = args[3];
    String serialization = args[4];
    System.out.println(dateFormat.format(new Date()) + " ready to start server,listenPort is: " + listenPort
            + ",maxThreads is:" + maxThreads + ",responseSize is:" + responseSize
            + " bytes,transporter is:" + transporter + ",serialization is:" + serialization);
    StringBuilder url = new StringBuilder();
    url.append("exchange://0.0.0.0:");
    url.append(listenPort);
    url.append("?transporter=");
    url.append(transporter);
    url.append("&serialization=");
    url.append(serialization);
    url.append("&threads=");
    url.append(maxThreads);
    Exchangers.bind(url.toString(), new ExchangeHandlerAdapter() {

        @Override
        public Object reply(ExchangeChannel channel, Object message) throws RemotingException {
            return new ResponseObject(responseSize); // send response
        }
    });
}
 
Example #2
Source File: AbstractBenchmarkServer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void run(String[] args) throws Exception {
    if (args == null || args.length != 5) {
        throw new IllegalArgumentException(
                                           "must give three args: listenPort | maxThreads | responseSize | transporter | serialization");
    }
    int listenPort = Integer.parseInt(args[0]);
    int maxThreads = Integer.parseInt(args[1]);
    final int responseSize = Integer.parseInt(args[2]);
    String transporter = args[3];
    String serialization = args[4];
    System.out.println(dateFormat.format(new Date()) + " ready to start server,listenPort is: " + listenPort
                       + ",maxThreads is:" + maxThreads + ",responseSize is:" + responseSize
                       + " bytes,transporter is:" + transporter + ",serialization is:" + serialization);
    StringBuilder url = new StringBuilder();
    url.append("exchange://0.0.0.0:");
    url.append(listenPort);
    url.append("?transporter=");
    url.append(transporter);
    url.append("&serialization=");
    url.append(serialization);
    url.append("&threads=");
    url.append(maxThreads);
    Exchangers.bind(url.toString(), new ExchangeHandlerAdapter() {

        public Object reply(ExchangeChannel channel, Object message) throws RemotingException {
            return new ResponseObject(responseSize); // 发送响应
        }
    });
}
 
Example #3
Source File: AbstractBenchmarkServer.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public void run(String[] args) throws Exception {
    if (args == null || args.length != 5) {
        throw new IllegalArgumentException(
                                           "must give three args: listenPort | maxThreads | responseSize | transporter | serialization");
    }
    int listenPort = Integer.parseInt(args[0]);
    int maxThreads = Integer.parseInt(args[1]);
    final int responseSize = Integer.parseInt(args[2]);
    String transporter = args[3];
    String serialization = args[4];
    System.out.println(dateFormat.format(new Date()) + " ready to start server,listenPort is: " + listenPort
                       + ",maxThreads is:" + maxThreads + ",responseSize is:" + responseSize
                       + " bytes,transporter is:" + transporter + ",serialization is:" + serialization);
    StringBuilder url = new StringBuilder();
    url.append("exchange://0.0.0.0:");
    url.append(listenPort);
    url.append("?transporter=");
    url.append(transporter);
    url.append("&serialization=");
    url.append(serialization);
    url.append("&threads=");
    url.append(maxThreads);
    Exchangers.bind(url.toString(), new ExchangeHandlerAdapter() {

        public Object reply(ExchangeChannel channel, Object message) throws RemotingException {
            return new ResponseObject(responseSize); // 发送响应
        }
    });
}
 
Example #4
Source File: AbstractBenchmarkServer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void run(String[] args) throws Exception {
    if (args == null || args.length != 5) {
        throw new IllegalArgumentException(
                                           "must give three args: listenPort | maxThreads | responseSize | transporter | serialization");
    }
    int listenPort = Integer.parseInt(args[0]);
    int maxThreads = Integer.parseInt(args[1]);
    final int responseSize = Integer.parseInt(args[2]);
    String transporter = args[3];
    String serialization = args[4];
    System.out.println(dateFormat.format(new Date()) + " ready to start server,listenPort is: " + listenPort
                       + ",maxThreads is:" + maxThreads + ",responseSize is:" + responseSize
                       + " bytes,transporter is:" + transporter + ",serialization is:" + serialization);
    StringBuilder url = new StringBuilder();
    url.append("exchange://0.0.0.0:");
    url.append(listenPort);
    url.append("?transporter=");
    url.append(transporter);
    url.append("&serialization=");
    url.append(serialization);
    url.append("&threads=");
    url.append(maxThreads);
    Exchangers.bind(url.toString(), new ExchangeHandlerAdapter() {

        public Object reply(ExchangeChannel channel, Object message) throws RemotingException {
            return new ResponseObject(responseSize); // 发送响应
        }
    });
}
 
Example #5
Source File: AbstractBenchmarkServer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void run(String[] args) throws Exception {
    if (args == null || args.length != 5) {
        throw new IllegalArgumentException(
                                           "must give three args: listenPort | maxThreads | responseSize | transporter | serialization");
    }
    int listenPort = Integer.parseInt(args[0]);
    int maxThreads = Integer.parseInt(args[1]);
    final int responseSize = Integer.parseInt(args[2]);
    String transporter = args[3];
    String serialization = args[4];
    System.out.println(dateFormat.format(new Date()) + " ready to start server,listenPort is: " + listenPort
                       + ",maxThreads is:" + maxThreads + ",responseSize is:" + responseSize
                       + " bytes,transporter is:" + transporter + ",serialization is:" + serialization);
    StringBuilder url = new StringBuilder();
    url.append("exchange://0.0.0.0:");
    url.append(listenPort);
    url.append("?transporter=");
    url.append(transporter);
    url.append("&serialization=");
    url.append(serialization);
    url.append("&threads=");
    url.append(maxThreads);
    Exchangers.bind(url.toString(), new ExchangeHandlerAdapter() {

        public Object reply(ExchangeChannel channel, Object message) throws RemotingException {
            return new ResponseObject(responseSize); // 发送响应
        }
    });
}