当前位置: 首页>>代码示例>>Java>>正文


Java WriteFuture.join方法代码示例

本文整理汇总了Java中org.apache.mina.common.WriteFuture.join方法的典型用法代码示例。如果您正苦于以下问题:Java WriteFuture.join方法的具体用法?Java WriteFuture.join怎么用?Java WriteFuture.join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.mina.common.WriteFuture的用法示例。


在下文中一共展示了WriteFuture.join方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: send

import org.apache.mina.common.WriteFuture; //导入方法依赖的package包/类
public void send(Object message, boolean sent) throws RemotingException {
    super.send(message, sent);
    
    boolean success = true;
    int timeout = 0;
    try {
        WriteFuture future = session.write(message);
        if (sent) {
            timeout = getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
            success = future.join(timeout);
        }
    } catch (Throwable e) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + ", cause: " + e.getMessage(), e);
    }
    
    if(!success) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress()
                + "in timeout(" + timeout + "ms) limit");
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:21,代码来源:MinaChannel.java

示例2: send

import org.apache.mina.common.WriteFuture; //导入方法依赖的package包/类
public void send(Object message, boolean sent) throws RemotingException {
    if (isClosed()) {
        throw new RemotingException(this, "Failed to send message "
                + (message == null ? "" : message.getClass().getName()) + ":" + message
                + ", cause: Channel closed. channel: " + getLocalAddress() + " -> " + getRemoteAddress());
    }
    boolean success = true;
    int timeout = 0;
    try {
        WriteFuture future = session.write(message);
        if (sent) {
            timeout = getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
            success = future.join(timeout);
        }
    } catch (Throwable e) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + ", cause: " + e.getMessage(), e);
    }

    if(!success) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress()
                + "in timeout(" + timeout + "ms) limit");
    }
}
 
开发者ID:xyp260466,项目名称:dubbo-lite,代码行数:24,代码来源:MinaChannel.java

示例3: send

import org.apache.mina.common.WriteFuture; //导入方法依赖的package包/类
public void send(Object message, boolean sent) throws RemotingException {
    super.send(message, sent);

    boolean success = true;
    int timeout = 0;
    try {
        WriteFuture future = session.write(message);
        if (sent) {
            timeout = getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
            success = future.join(timeout);
        }
    } catch (Throwable e) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + ", cause: " + e.getMessage(), e);
    }

    if (!success) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress()
                + "in timeout(" + timeout + "ms) limit");
    }
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:21,代码来源:MinaChannel.java

示例4: writeBody

import org.apache.mina.common.WriteFuture; //导入方法依赖的package包/类
/**
 * Asynchronously writes the given body to MINA session. Will wait at most for
 * 10 seconds until the body has been written.
 *
 * @param session  the MINA session
 * @param body     the body to write (send)
 * @param exchange the exchange
 * @throws CamelExchangeException is thrown if the body could not be written for some reasons
 *                                (eg remote connection is closed etc.)
 */
public static void writeBody(IoSession session, Object body, Exchange exchange) throws CamelExchangeException {
    // the write operation is asynchronous. Use WriteFuture to wait until the session has been written
    WriteFuture future = session.write(body);
    // must use a timeout (we use 10s) as in some very high performance scenarios a write can cause 
    // thread hanging forever
    LOG.trace("Waiting for write to complete for body: {} using session: {}", body, session);
    future.join(10000L);
    if (!future.isWritten()) {
        throw new CamelExchangeException("Cannot write body: " + body + " using session: " + session, exchange);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:MinaHelper.java


注:本文中的org.apache.mina.common.WriteFuture.join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。