Search in sources :

Example 1 with GrizzlyFuture

use of org.glassfish.grizzly.GrizzlyFuture in project dubbo by alibaba.

the class GrizzlyChannel method send.

@SuppressWarnings("rawtypes")
public void send(Object message, boolean sent) throws RemotingException {
    super.send(message, sent);
    int timeout = 0;
    try {
        GrizzlyFuture future = connection.write(message);
        if (sent) {
            timeout = getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
            future.get(timeout, TimeUnit.MILLISECONDS);
        }
    } catch (TimeoutException e) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + "in timeout(" + timeout + "ms) limit", e);
    } catch (Throwable e) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + ", cause: " + e.getMessage(), e);
    }
}
Also used : RemotingException(com.alibaba.dubbo.remoting.RemotingException) GrizzlyFuture(org.glassfish.grizzly.GrizzlyFuture) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

RemotingException (com.alibaba.dubbo.remoting.RemotingException)1 TimeoutException (java.util.concurrent.TimeoutException)1 GrizzlyFuture (org.glassfish.grizzly.GrizzlyFuture)1