• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java InvokeCallback类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中com.alibaba.rocketmq.remoting.InvokeCallback的典型用法代码示例。如果您正苦于以下问题:Java InvokeCallback类的具体用法?Java InvokeCallback怎么用?Java InvokeCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

InvokeCallback类属于com.alibaba.rocketmq.remoting包,在下文中一共展示了InvokeCallback类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: queryMessage

点赞 3

import com.alibaba.rocketmq.remoting.InvokeCallback; //导入依赖的package包/类
/**
 * 查询消息
 */
public void queryMessage(//
        final String addr,//
        final QueryMessageRequestHeader requestHeader,//
        final long timeoutMillis,//
        final InvokeCallback invokeCallback//
) throws RemotingException, MQBrokerException, InterruptedException {
    // 添加虚拟运行环境相关的projectGroupPrefix
    if (!UtilAll.isBlank(projectGroupPrefix)) {
        requestHeader.setTopic(VirtualEnvUtil.buildWithProjectGroup(requestHeader.getTopic(),
            projectGroupPrefix));
    }

    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.QUERY_MESSAGE, requestHeader);

    this.remotingClient.invokeAsync(addr, request, timeoutMillis, invokeCallback);
}
 

开发者ID:diwayou,
项目名称:rocketmq-all-trans,
代码行数:21,
代码来源:MQClientAPIImpl.java

示例2: invokeAsync

点赞 3

import com.alibaba.rocketmq.remoting.InvokeCallback; //导入依赖的package包/类
@Override
public void invokeAsync(String addr, RemotingCommand request, long timeoutMillis,
        InvokeCallback invokeCallback) throws InterruptedException, RemotingConnectException,
        RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
    final Channel channel = this.getAndCreateChannel(addr);
    if (channel != null && channel.isActive()) {
        try {
            if (this.rpcHook != null) {
                this.rpcHook.doBeforeRequest(addr, request);
            }
            this.invokeAsyncImpl(channel, request, timeoutMillis, invokeCallback);
        }
        catch (RemotingSendRequestException e) {
            log.warn("invokeAsync: send request exception, so close the channel[{}]", addr);
            this.closeChannel(addr, channel);
            throw e;
        }
    }
    else {
        this.closeChannel(addr, channel);
        throw new RemotingConnectException(addr);
    }
}
 

开发者ID:diwayou,
项目名称:rocketmq-all-trans,
代码行数:24,
代码来源:NettyRemotingClient.java

示例3: queryMessage

点赞 3

import com.alibaba.rocketmq.remoting.InvokeCallback; //导入依赖的package包/类
/**
 * 查询消息
 */
public void queryMessage(//
        final String addr,//
        final QueryMessageRequestHeader requestHeader,//
        final long timeoutMillis,//
        final InvokeCallback invokeCallback//
) throws RemotingException, MQBrokerException, InterruptedException {
    // 添加虚拟运行环境相关的projectGroupPrefix
    if (!UtilAll.isBlank(projectGroupPrefix)) {
        requestHeader.setTopic(VirtualEnvUtil.buildWithProjectGroup(requestHeader.getTopic(),
            projectGroupPrefix));
    }

    RemotingCommand request =
            RemotingCommand.createRequestCommand(MQRequestCode.QUERY_MESSAGE_VALUE, requestHeader);
    this.remotingClient.invokeAsync(addr, request, timeoutMillis, invokeCallback);
}
 

开发者ID:brucechan0921,
项目名称:RocketMQ-3.0.8,
代码行数:20,
代码来源:MQClientAPIImpl.java

示例4: invokeAsync

点赞 3

import com.alibaba.rocketmq.remoting.InvokeCallback; //导入依赖的package包/类
@Override
public void invokeAsync(String addr, RemotingCommand request, long timeoutMillis,
        InvokeCallback invokeCallback) throws InterruptedException, RemotingConnectException,
        RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
    final Channel channel = this.getAndCreateChannel(addr);
    if (channel != null && channel.isActive()) {
        try {
            this.invokeAsyncImpl(channel, request, timeoutMillis, invokeCallback);
        }
        catch (RemotingSendRequestException e) {
            log.warn("invokeAsync: send request exception, so close the channel[{}]", addr);
            this.closeChannel(addr, channel);
            throw e;
        }
    }
    else {
        this.closeChannel(addr, channel);
        throw new RemotingConnectException(addr);
    }
}
 

开发者ID:brucechan0921,
项目名称:RocketMQ-3.0.8,
代码行数:21,
代码来源:NettyRemotingClient.java

示例5: queryMessage

点赞 2

import com.alibaba.rocketmq.remoting.InvokeCallback; //导入依赖的package包/类
public void queryMessage(//
        final String addr,//
        final QueryMessageRequestHeader requestHeader,//
        final long timeoutMillis,//
        final InvokeCallback invokeCallback//
) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_MESSAGE, requestHeader);

    this.remotingClient.invokeAsync(addr, request, timeoutMillis, invokeCallback);
}
 

开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:11,
代码来源:MQClientAPIImpl.java

示例6: invokeAsync

点赞 2

import com.alibaba.rocketmq.remoting.InvokeCallback; //导入依赖的package包/类
@Override //异步从addr地址获取报文信息.
public void invokeAsync(String addr, RemotingCommand request, long timeoutMillis,
        InvokeCallback invokeCallback) throws InterruptedException, RemotingConnectException,
        RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
    final Channel channel = this.getAndCreateChannel(addr);
    if (channel != null && channel.isActive()) {
        // test the channel writable or not
        if (!channel.isWritable()) {
            throw new RemotingTooMuchRequestException(String.format(
                "the channel[%s] is not writable now", channel.toString()));
        }

        try {
            if (this.rpcHook != null) {
                this.rpcHook.doBeforeRequest(addr, request);
            }
            this.invokeAsyncImpl(channel, request, timeoutMillis, invokeCallback);
        }
        catch (RemotingSendRequestException e) {
            log.warn("invokeAsync: send request exception, so close the channel[{}]", addr);
            this.closeChannel(addr, channel);
            throw e;
        }
    }
    else {
        this.closeChannel(addr, channel);
        throw new RemotingConnectException(addr);
    }
}
 

开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:30,
代码来源:NettyRemotingClient.java

示例7: ResponseFuture

点赞 2

import com.alibaba.rocketmq.remoting.InvokeCallback; //导入依赖的package包/类
public ResponseFuture(int opaque, long timeoutMillis, InvokeCallback invokeCallback,
        SemaphoreReleaseOnlyOnce once) {
    this.opaque = opaque;
    this.timeoutMillis = timeoutMillis;
    this.invokeCallback = invokeCallback;
    this.once = once;
}
 

开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:8,
代码来源:ResponseFuture.java

示例8: queryMessage

点赞 2

import com.alibaba.rocketmq.remoting.InvokeCallback; //导入依赖的package包/类
public void queryMessage(//
                         final String addr,//
                         final QueryMessageRequestHeader requestHeader,//
                         final long timeoutMillis,//
                         final InvokeCallback invokeCallback//
) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_MESSAGE, requestHeader);

    this.remotingClient.invokeAsync(addr, request, timeoutMillis, invokeCallback);
}
 

开发者ID:medusar,
项目名称:rocketmq-commet,
代码行数:11,
代码来源:MQClientAPIImpl.java

示例9: invokeAsync

点赞 2

import com.alibaba.rocketmq.remoting.InvokeCallback; //导入依赖的package包/类
/**
 * 客户端异步调用服务端
 *
 * @param addr           服务端地址
 * @param request        请求内容
 * @param timeoutMillis  客户端超时时间
 * @param invokeCallback 回调方法
 * @throws InterruptedException
 * @throws RemotingConnectException
 * @throws RemotingTooMuchRequestException
 * @throws RemotingTimeoutException
 * @throws RemotingSendRequestException
 */
@Override
public void invokeAsync(String addr, RemotingCommand request, long timeoutMillis,
                        InvokeCallback invokeCallback) throws InterruptedException, RemotingConnectException,
        RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
    /**
     * 获取或者创建与服务端的通道
     */
    final Channel channel = this.getAndCreateChannel(addr);
    if (channel != null && channel.isActive()) {
        // test the channel writable or not
        if (!channel.isWritable()) {
            throw new RemotingTooMuchRequestException(String.format(
                    "the channel[%s] is not writable now", channel.toString()));
        }

        try {
            /**
             * 执行切面方法
             */
            if (this.rpcHook != null) {
                this.rpcHook.doBeforeRequest(addr, request);
            }

            /**
             * 发起异步调用
             */
            this.invokeAsyncImpl(channel, request, timeoutMillis, invokeCallback);
        } catch (RemotingSendRequestException e) {
            log.warn("invokeAsync: send request exception, so close the channel[{}]", addr);
            this.closeChannel(addr, channel);
            throw e;
        }
    } else {
        this.closeChannel(addr, channel);
        throw new RemotingConnectException(addr);
    }
}
 

开发者ID:medusar,
项目名称:rocketmq-commet,
代码行数:51,
代码来源:NettyRemotingClient.java

示例10: invokeAsync

点赞 2

import com.alibaba.rocketmq.remoting.InvokeCallback; //导入依赖的package包/类
@Override
public void invokeAsync(Channel channel, RemotingCommand request, long timeoutMillis, InvokeCallback invokeCallback)
        throws InterruptedException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
    this.invokeAsyncImpl(channel, request, timeoutMillis, invokeCallback);
}
 

开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:6,
代码来源:NettyRemotingServer.java

示例11: getInvokeCallback

点赞 2

import com.alibaba.rocketmq.remoting.InvokeCallback; //导入依赖的package包/类
public InvokeCallback getInvokeCallback() {
    return invokeCallback;
}
 

开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:4,
代码来源:ResponseFuture.java

示例12: invokeAsync

点赞 2

import com.alibaba.rocketmq.remoting.InvokeCallback; //导入依赖的package包/类
@Override
public void invokeAsync(Channel channel, RemotingCommand request, long timeoutMillis,
        InvokeCallback invokeCallback) throws InterruptedException, RemotingTooMuchRequestException,
        RemotingTimeoutException, RemotingSendRequestException {
    this.invokeAsyncImpl(channel, request, timeoutMillis, invokeCallback);
}
 

开发者ID:diwayou,
项目名称:rocketmq-all-trans,
代码行数:7,
代码来源:NettyRemotingServer.java

示例13: invokeAsyncImpl

点赞 2

import com.alibaba.rocketmq.remoting.InvokeCallback; //导入依赖的package包/类
public void invokeAsyncImpl(final Channel channel, final RemotingCommand request,
        final long timeoutMillis, final InvokeCallback invokeCallback) throws InterruptedException,
        RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
    boolean acquired = this.semaphoreAsync.tryAcquire(timeoutMillis, TimeUnit.MILLISECONDS);
    if (acquired) {
        final SemaphoreReleaseOnlyOnce once = new SemaphoreReleaseOnlyOnce(this.semaphoreAsync);

        final ResponseFuture responseFuture =
                new ResponseFuture(request.getOpaque(), timeoutMillis, invokeCallback, once);
        this.responseTable.put(request.getOpaque(), responseFuture);
        try {
            channel.writeAndFlush(request).addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture f) throws Exception {
                    if (f.isSuccess()) {
                        responseFuture.setSendRequestOK(true);
                        return;
                    }
                    else {
                        responseFuture.setSendRequestOK(false);
                    }

                    responseFuture.putResponse(null);
                    responseFuture.executeInvokeCallback();

                    responseTable.remove(request.getOpaque());
                    plog.warn("send a request command to channel <" + channel.remoteAddress()
                            + "> failed.");
                    plog.warn(request.toString());

                }
            });
        }
        catch (Exception e) {
            once.release();
            plog.warn("write send a request command to channel <" + channel.remoteAddress() + "> failed.");
            throw new RemotingSendRequestException(RemotingHelper.parseChannelRemoteAddr(channel), e);
        }
    }
    else {
        if (timeoutMillis <= 0) {
            throw new RemotingTooMuchRequestException("invokeAsyncImpl invoke too fast");
        }
        else {
            plog.warn("invokeAsyncImpl tryAcquire semaphore timeout, " + timeoutMillis
                    + " waiting thread nums: " + this.semaphoreAsync.getQueueLength());
            plog.warn(request.toString());

            throw new RemotingTimeoutException("tryAcquire timeout(ms) " + timeoutMillis);
        }
    }
}
 

开发者ID:diwayou,
项目名称:rocketmq-all-trans,
代码行数:53,
代码来源:NettyRemotingAbstract.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)