Search in sources :

Example 1 with ReplierDispatcher

use of com.alibaba.dubbo.remoting.exchange.support.ReplierDispatcher in project dubbo by alibaba.

the class Main method startServer.

private static void startServer(int port) throws Exception {
    ReplierDispatcher dispatcher = new ReplierDispatcher();
    dispatcher.addReplier(RpcMessage.class, new RpcMessageHandler());
    dispatcher.addReplier(Object.class, new Replier<Object>() {

        public Object reply(ExchangeChannel channel, Object msg) {
            for (int i = 0; i < 10000; i++) System.currentTimeMillis();
            System.out.println("handle:" + msg + ";thread:" + Thread.currentThread().getName());
            return new StringMessage("hello world");
        }
    });
    Exchangers.bind(URL.valueOf("dubbo://localhost:" + port), dispatcher);
}
Also used : ReplierDispatcher(com.alibaba.dubbo.remoting.exchange.support.ReplierDispatcher) ExchangeChannel(com.alibaba.dubbo.remoting.exchange.ExchangeChannel)

Aggregations

ExchangeChannel (com.alibaba.dubbo.remoting.exchange.ExchangeChannel)1 ReplierDispatcher (com.alibaba.dubbo.remoting.exchange.support.ReplierDispatcher)1