com.alibaba.dubbo.remoting.exchange.ExchangeChannel Java Examples

The following examples show how to use com.alibaba.dubbo.remoting.exchange.ExchangeChannel. 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: HeaderExchangeHandler.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public void caught(Channel channel, Throwable exception) throws RemotingException {
    if (exception instanceof ExecutionException) {
        ExecutionException e = (ExecutionException) exception;
        Object msg = e.getRequest();
        if (msg instanceof Request) {
            Request req = (Request) msg;
            if (req.isTwoWay() && ! req.isHeartbeat()) {
                Response res = new Response(req.getId(), req.getVersion());
                res.setStatus(Response.SERVER_ERROR);
                res.setErrorMessage(StringUtils.toString(e));
                channel.send(res);
                return;
            }
        }
    }
    ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
    try {
        handler.caught(exchangeChannel, exception);
    } finally {
        HeaderExchangeChannel.removeChannelIfDisconnected(channel);
    }
}
 
Example #2
Source File: HeaderExchangeHandler.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
public void caught(Channel channel, Throwable exception) throws RemotingException {
    if (exception instanceof ExecutionException) {
        ExecutionException e = (ExecutionException) exception;
        Object msg = e.getRequest();
        if (msg instanceof Request) {
            Request req = (Request) msg;
            if (req.isTwoWay() && ! req.isHeartbeat()) {
                Response res = new Response(req.getId(), req.getVersion());
                res.setStatus(Response.SERVER_ERROR);
                res.setErrorMessage(StringUtils.toString(e));
                channel.send(res);
                return;
            }
        }
    }
    ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
    try {
        handler.caught(exchangeChannel, exception);
    } finally {
        HeaderExchangeChannel.removeChannelIfDisconnected(channel);
    }
}
 
Example #3
Source File: HeaderExchangeHandler.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public void caught(Channel channel, Throwable exception) throws RemotingException {
    if (exception instanceof ExecutionException) {
        ExecutionException e = (ExecutionException) exception;
        Object msg = e.getRequest();
        if (msg instanceof Request) {
            Request req = (Request) msg;
            if (req.isTwoWay() && ! req.isHeartbeat()) {
                Response res = new Response(req.getId(), req.getVersion());
                res.setStatus(Response.SERVER_ERROR);
                res.setErrorMessage(StringUtils.toString(e));
                channel.send(res);
                return;
            }
        }
    }
    ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
    try {
        handler.caught(exchangeChannel, exception);
    } finally {
        HeaderExchangeChannel.removeChannelIfDisconnected(channel);
    }
}
 
Example #4
Source File: TelnetServerHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Object reply(ExchangeChannel channel, String msg) throws RemotingException {
    // Generate and write a response.

    String response;
    if (msg.length() == 0) {
        response = "Please type something.\r\n";
    }  else {
        response = "Did you say '" + msg + "'?\r\n";
    }
    //System.out.println(response);
    return response;
}
 
Example #5
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 #6
Source File: DubboProtocol.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public Object reply(ExchangeChannel channel, Object message) throws RemotingException {
    if (message instanceof Invocation) {
        Invocation inv = (Invocation) message;
        Invoker<?> invoker = getInvoker(channel, inv);
        //如果是callback 需要处理高版本调用低版本的问题
        if (Boolean.TRUE.toString().equals(inv.getAttachments().get(IS_CALLBACK_SERVICE_INVOKE))){
            String methodsStr = invoker.getUrl().getParameters().get("methods");
            boolean hasMethod = false;
            if (methodsStr == null || methodsStr.indexOf(",") == -1){
                hasMethod = inv.getMethodName().equals(methodsStr);
            } else {
                String[] methods = methodsStr.split(",");
                for (String method : methods){
                    if (inv.getMethodName().equals(method)){
                        hasMethod = true;
                        break;
                    }
                }
            }
            if (!hasMethod){
                logger.warn(new IllegalStateException("The methodName "+inv.getMethodName()+" not found in callback service interface ,invoke will be ignored. please update the api interface. url is:" + invoker.getUrl()) +" ,invocation is :"+inv );
                return null;
            }
        }
        RpcContext.getContext().setRemoteAddress(channel.getRemoteAddress());
        return invoker.invoke(inv);
    }
    throw new RemotingException(channel, "Unsupported request: " + message == null ? null : (message.getClass().getName() + ": " + message) + ", channel: consumer: " + channel.getRemoteAddress() + " --> provider: " + channel.getLocalAddress());
}
 
Example #7
Source File: ThriftProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public Object reply( ExchangeChannel channel, Object msg ) throws RemotingException {

    if ( msg instanceof Invocation ) {
        Invocation inv = ( Invocation ) msg;
        String serviceName = inv.getAttachments().get(Constants.INTERFACE_KEY);
        String serviceKey = serviceKey( channel.getLocalAddress().getPort(),
                                        serviceName, null, null );
        DubboExporter<?> exporter = (DubboExporter<?>) exporterMap.get( serviceKey );
        if (exporter == null) {
            throw new RemotingException(channel,
                                        "Not found exported service: "
                                                + serviceKey
                                                + " in "
                                                + exporterMap.keySet()
                                                + ", may be version or group mismatch "
                                                + ", channel: consumer: "
                                                + channel.getRemoteAddress()
                                                + " --> provider: "
                                                + channel.getLocalAddress()
                                                + ", message:"+ msg);
        }

        RpcContext.getContext().setRemoteAddress(channel.getRemoteAddress());
        return exporter.getInvoker().invoke( inv );

    }

    throw new RemotingException(channel,
                                "Unsupported request: "
                                        + (msg.getClass().getName() + ": " + msg)
                                        + ", channel: consumer: "
                                        + channel.getRemoteAddress()
                                        + " --> provider: "
                                        + channel.getLocalAddress());
}
 
Example #8
Source File: ThriftProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public void received( Channel channel, Object message ) throws RemotingException {
    if ( message instanceof Invocation ) {
        reply( ( ExchangeChannel ) channel, message );
    } else {
        super.received( channel, message );
    }
}
 
Example #9
Source File: TelnetServerHandler.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public Object reply(ExchangeChannel channel, String msg) throws RemotingException {
    // Generate and write a response.

    String response;
    if (msg.length() == 0) {
        response = "Please type something.\r\n";
    }  else {
        response = "Did you say '" + msg + "'?\r\n";
    }
    //System.out.println(response);
    return response;
}
 
Example #10
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 #11
Source File: HeaderExchangeHandler.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
    public void received(Channel channel, Object message) throws RemotingException {
        channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis());
//        查询channel
        ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
        try {
            if (message instanceof Request) {
                // handle request.
                Request request = (Request) message;
                if (request.isEvent()) {
                    handlerEvent(channel, request);
                } else {
                    if (request.isTwoWay()) {
                        Response response = handleRequest(exchangeChannel, request);
//                        消息发送com.alibaba.dubbo.remoting.transport.AbstractPeer.send()
                        channel.send(response);
                    } else {
                        handler.received(exchangeChannel, request.getData());
                    }
                }
            } else if (message instanceof Response) {
//                =》
                handleResponse(channel, (Response) message);
            } else if (message instanceof String) {
                if (isClientSide(channel)) {
                    Exception e = new Exception("Dubbo client can not supported string message: " + message + " in channel: " + channel + ", url: " + channel.getUrl());
                    logger.error(e.getMessage(), e);
                } else {
                    String echo = handler.telnet(channel, (String) message);
                    if (echo != null && echo.length() > 0) {
                        channel.send(echo);
                    }
                }
            } else {
                handler.received(exchangeChannel, message);
            }
        } finally {
            HeaderExchangeChannel.removeChannelIfDisconnected(channel);
        }
    }
 
Example #12
Source File: HeaderExchangeHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void received(Channel channel, Object message) throws RemotingException {
    channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis());
    ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
    try {
        if (message instanceof Request) {
            // handle request.
            Request request = (Request) message;
            if (request.isEvent()) {
                handlerEvent(channel, request);
            } else {
                if (request.isTwoWay()) {
                    Response response = handleRequest(exchangeChannel, request);
                    channel.send(response);
                } else {
                    handler.received(exchangeChannel, request.getData());
                }
            }
        } else if (message instanceof Response) {
            handleResponse(channel, (Response) message);
        } else if (message instanceof String) {
            if (isClientSide(channel)) {
                Exception e = new Exception("Dubbo client can not supported string message: " + message + " in channel: " + channel + ", url: " + channel.getUrl());
                logger.error(e.getMessage(), e);
            } else {
                String echo = handler.telnet(channel, (String) message);
                if (echo != null && echo.length() > 0) {
                    channel.send(echo);
                }
            }
        } else {
            handler.received(exchangeChannel, message);
        }
    } finally {
        HeaderExchangeChannel.removeChannelIfDisconnected(channel);
    }
}
 
Example #13
Source File: Main.java    From dubbox with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #14
Source File: ExchangeServerPeer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public ExchangeChannel getExchangeChannel(InetSocketAddress remoteAddress) {
    String host = remoteAddress.getAddress() != null ? remoteAddress.getAddress().getHostAddress() : remoteAddress.getHostName();
    int port = remoteAddress.getPort();
    ExchangeChannel channel = super.getExchangeChannel(remoteAddress);
    if (channel == null) {
        for (Map.Entry<URL, ExchangeClient> entry : clients.entrySet()) {
            URL url = entry.getKey();
            if (url.getIp().equals(host) && url.getPort() == port) {
                return entry.getValue();
            }
        }
    }
    return channel;
}
 
Example #15
Source File: HeaderExchangeHandler.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public void received(Channel channel, Object message) throws RemotingException {
    channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis());
    ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
    try {
        if (message instanceof Request) {
            // handle request.
            Request request = (Request) message;
            if (request.isEvent()) {
                handlerEvent(channel, request);
            } else {
                if (request.isTwoWay()) {
                    Response response = handleRequest(exchangeChannel, request);
                    channel.send(response);
                } else {
                    handler.received(exchangeChannel, request.getData());
                }
            }
        } else if (message instanceof Response) {
            handleResponse(channel, (Response) message);
        } else if (message instanceof String) {
            if (isClientSide(channel)) {
                Exception e = new Exception("Dubbo client can not supported string message: " + message + " in channel: " + channel + ", url: " + channel.getUrl());
                logger.error(e.getMessage(), e);
            } else {
                String echo = handler.telnet(channel, (String) message);
                if (echo != null && echo.length() > 0) {
                    channel.send(echo);
                }
            }
        } else {
            handler.received(exchangeChannel, message);
        }
    } finally {
        HeaderExchangeChannel.removeChannelIfDisconnected(channel);
    }
}
 
Example #16
Source File: HeaderExchangeHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void connected(Channel channel) throws RemotingException {
    channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis());
    channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis());
    ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
    try {
        handler.connected(exchangeChannel);
    } finally {
        HeaderExchangeChannel.removeChannelIfDisconnected(channel);
    }
}
 
Example #17
Source File: DubboProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public void received(Channel channel, Object message) throws RemotingException {
    if (message instanceof Invocation) {
        reply((ExchangeChannel) channel, message);
    } else {
        super.received(channel, message);
    }
}
 
Example #18
Source File: HeaderExchangeHandler.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
public void sent(Channel channel, Object message) throws RemotingException {
    Throwable exception = null;
    try {
        channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis());
        ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
        try {
            handler.sent(exchangeChannel, message);
        } finally {
            HeaderExchangeChannel.removeChannelIfDisconnected(channel);
        }
    } catch (Throwable t) {
        exception = t;
    }
    if (message instanceof Request) {
        Request request = (Request) message;
        DefaultFuture.sent(channel, request);
    }
    if (exception != null) {
        if (exception instanceof RuntimeException) {
            throw (RuntimeException) exception;
        } else if (exception instanceof RemotingException) {
            throw (RemotingException) exception;
        } else {
            throw new RemotingException(channel.getLocalAddress(), channel.getRemoteAddress(),
                    exception.getMessage(), exception);
        }
    }
}
 
Example #19
Source File: ExchangeServerPeer.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@Override
public ExchangeChannel getExchangeChannel(InetSocketAddress remoteAddress) {
    String host = remoteAddress.getAddress() != null ? remoteAddress.getAddress().getHostAddress() : remoteAddress.getHostName();
    int port = remoteAddress.getPort();
    ExchangeChannel channel = super.getExchangeChannel(remoteAddress);
    if (channel == null) {
        for (Map.Entry<URL, ExchangeClient> entry : clients.entrySet()) {
            URL url = entry.getKey();
            if (url.getIp().equals(host) && url.getPort() == port) {
                return entry.getValue();
            }
        }
    }
    return channel;
}
 
Example #20
Source File: TelnetServerHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Object reply(ExchangeChannel channel, String msg) throws RemotingException {
    // Generate and write a response.

    String response;
    if (msg.length() == 0) {
        response = "Please type something.\r\n";
    }  else {
        response = "Did you say '" + msg + "'?\r\n";
    }
    //System.out.println(response);
    return response;
}
 
Example #21
Source File: DubboProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Object reply(ExchangeChannel channel, Object message) throws RemotingException {
    if (message instanceof Invocation) {
        Invocation inv = (Invocation) message;
        Invoker<?> invoker = getInvoker(channel, inv);
        //如果是callback 需要处理高版本调用低版本的问题
        if (Boolean.TRUE.toString().equals(inv.getAttachments().get(IS_CALLBACK_SERVICE_INVOKE))){
            String methodsStr = invoker.getUrl().getParameters().get("methods");
            boolean hasMethod = false;
            if (methodsStr == null || methodsStr.indexOf(",") == -1){
                hasMethod = inv.getMethodName().equals(methodsStr);
            } else {
                String[] methods = methodsStr.split(",");
                for (String method : methods){
                    if (inv.getMethodName().equals(method)){
                        hasMethod = true;
                        break;
                    }
                }
            }
            if (!hasMethod){
                logger.warn(new IllegalStateException("The methodName "+inv.getMethodName()+" not found in callback service interface ,invoke will be ignored. please update the api interface. url is:" + invoker.getUrl()) +" ,invocation is :"+inv );
                return null;
            }
        }
        RpcContext.getContext().setRemoteAddress(channel.getRemoteAddress());
        return invoker.invoke(inv);
    }
    throw new RemotingException(channel, "Unsupported request: " + message == null ? null : (message.getClass().getName() + ": " + message) + ", channel: consumer: " + channel.getRemoteAddress() + " --> provider: " + channel.getLocalAddress());
}
 
Example #22
Source File: Main.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
static void dataPackageTest(int port) throws Exception {
    ExchangeChannel client = Exchangers.connect(URL.valueOf("dubbo://localhost:" + port));
    Random random = new Random();
    for (int i = 5; i < 100; i++) {
        StringBuilder sb = new StringBuilder();
        for (int j = 0; j < i * 100; j++)
            sb.append("(" + random.nextLong() + ")");
        Main.Data d = new Main.Data();
        d.setData(sb.toString());
        client.request(d).get();
    }
    System.out.println("send finished.");
}
 
Example #23
Source File: ExchangeServerPeer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public ExchangeChannel getExchangeChannel(InetSocketAddress remoteAddress) {
    String host = remoteAddress.getAddress() != null ? remoteAddress.getAddress().getHostAddress() : remoteAddress.getHostName();
    int port = remoteAddress.getPort();
    ExchangeChannel channel = super.getExchangeChannel(remoteAddress);
    if (channel == null) {
        for (Map.Entry<URL, ExchangeClient> entry : clients.entrySet()) {
            URL url = entry.getKey();
            if (url.getIp().equals(host) && url.getPort() == port) {
                return entry.getValue();
            }
        }
    }
    return channel;
}
 
Example #24
Source File: HeaderExchangeHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void connected(Channel channel) throws RemotingException {
    channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis());
    channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis());
    ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
    try {
        handler.connected(exchangeChannel);
    } finally {
        HeaderExchangeChannel.removeChannelIfDisconnected(channel);
    }
}
 
Example #25
Source File: HeaderExchangeServer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Collection<ExchangeChannel> getExchangeChannels() {
    Collection<ExchangeChannel> exchangeChannels  = new ArrayList<ExchangeChannel>();
    Collection<Channel> channels = server.getChannels();
    if (channels != null && channels.size() > 0) {
        for (Channel channel : channels) {
            exchangeChannels.add(HeaderExchangeChannel.getOrAddChannel(channel));
        }
    }
    return exchangeChannels;
}
 
Example #26
Source File: HeaderExchangeHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void disconnected(Channel channel) throws RemotingException {
    channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis());
    channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis());
    ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
    try {
        handler.disconnected(exchangeChannel);
    } finally {
        HeaderExchangeChannel.removeChannelIfDisconnected(channel);
    }
}
 
Example #27
Source File: DubboProtocol.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@Override
public void received(Channel channel, Object message) throws RemotingException {
    if (message instanceof Invocation) {
        reply((ExchangeChannel) channel, message);
    } else {
        super.received(channel, message);
    }
}
 
Example #28
Source File: TelnetServerHandler.java    From dubbo-remoting-netty4 with Apache License 2.0 5 votes vote down vote up
public Object reply(ExchangeChannel channel, String msg) throws RemotingException {
    // Generate and write a response.

    String response;
    if (msg.length() == 0) {
        response = "Please type something.\r\n";
    }  else {
        response = "Did you say '" + msg + "'?\r\n";
    }
    //System.out.println(response);
    return response;
}
 
Example #29
Source File: Main.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #30
Source File: HeaderExchangeServer.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public Collection<ExchangeChannel> getExchangeChannels() {
    Collection<ExchangeChannel> exchangeChannels  = new ArrayList<ExchangeChannel>();
    Collection<Channel> channels = server.getChannels();
    if (channels != null && channels.size() > 0) {
        for (Channel channel : channels) {
            exchangeChannels.add(HeaderExchangeChannel.getOrAddChannel(channel));
        }
    }
    return exchangeChannels;
}