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


Java PullCallback类代码示例

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


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

示例1: pullMessage

import org.apache.rocketmq.client.consumer.PullCallback; //导入依赖的package包/类
public PullResult pullMessage(//
    final String addr, //
    final PullMessageRequestHeader requestHeader, //
    final long timeoutMillis, //
    final CommunicationMode communicationMode, //
    final PullCallback pullCallback//
) throws RemotingException, MQBrokerException, InterruptedException {
	//发送PULL_MESSAGE类型的请求
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.PULL_MESSAGE, requestHeader);

    switch (communicationMode) {
        case ONEWAY:
            assert false;
            return null;
        case ASYNC:
            this.pullMessageAsync(addr, request, timeoutMillis, pullCallback);
            return null;
        case SYNC:
            return this.pullMessageSync(addr, request, timeoutMillis);
        default:
            assert false;
            break;
    }

    return null;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:27,代码来源:MQClientAPIImpl.java

示例2: pullMessage

import org.apache.rocketmq.client.consumer.PullCallback; //导入依赖的package包/类
public PullResult pullMessage(//
    final String addr, //
    final PullMessageRequestHeader requestHeader, //
    final long timeoutMillis, //
    final CommunicationMode communicationMode, //
    final PullCallback pullCallback//
) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.PULL_MESSAGE, requestHeader);

    switch (communicationMode) {
        case ONEWAY:
            assert false;
            return null;
        case ASYNC:
            this.pullMessageAsync(addr, request, timeoutMillis, pullCallback);
            return null;
        case SYNC:
            return this.pullMessageSync(addr, request, timeoutMillis);
        default:
            assert false;
            break;
    }

    return null;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:26,代码来源:MQClientAPIImpl.java

示例3: pullMessage

import org.apache.rocketmq.client.consumer.PullCallback; //导入依赖的package包/类
public PullResult pullMessage(
    final String addr,
    final PullMessageRequestHeader requestHeader,
    final long timeoutMillis,
    final CommunicationMode communicationMode,
    final PullCallback pullCallback
) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.PULL_MESSAGE, requestHeader);

    switch (communicationMode) {
        case ONEWAY:
            assert false;
            return null;
        case ASYNC:
            this.pullMessageAsync(addr, request, timeoutMillis, pullCallback);
            return null;
        case SYNC:
            return this.pullMessageSync(addr, request, timeoutMillis);
        default:
            assert false;
            break;
    }

    return null;
}
 
开发者ID:apache,项目名称:rocketmq,代码行数:26,代码来源:MQClientAPIImpl.java

示例4: pullKernelImpl

import org.apache.rocketmq.client.consumer.PullCallback; //导入依赖的package包/类
public PullResult pullKernelImpl(
    final MessageQueue mq,
    final String subExpression,
    final long subVersion,
    final long offset,
    final int maxNums,
    final int sysFlag,
    final long commitOffset,
    final long brokerSuspendMaxTimeMillis,
    final long timeoutMillis,
    final CommunicationMode communicationMode,
    final PullCallback pullCallback
) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
    return pullKernelImpl(
        mq,
        subExpression,
        ExpressionType.TAG,
        subVersion, offset,
        maxNums,
        sysFlag,
        commitOffset,
        brokerSuspendMaxTimeMillis,
        timeoutMillis,
        communicationMode,
        pullCallback
    );
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:28,代码来源:PullAPIWrapper.java

示例5: pullMessageAsync

import org.apache.rocketmq.client.consumer.PullCallback; //导入依赖的package包/类
private void pullMessageAsync(//
    final String addr, // 1
    final RemotingCommand request, //
    final long timeoutMillis, //
    final PullCallback pullCallback//
) throws RemotingException, InterruptedException {
    this.remotingClient.invokeAsync(addr, request, timeoutMillis, new InvokeCallback() {
        @Override
        public void operationComplete(ResponseFuture responseFuture) {
            RemotingCommand response = responseFuture.getResponseCommand();
            if (response != null) {
                try {
                    PullResult pullResult = MQClientAPIImpl.this.processPullResponse(response);
                    assert pullResult != null;
                    pullCallback.onSuccess(pullResult);
                } catch (Exception e) {
                    pullCallback.onException(e);
                }
            } else {
                if (!responseFuture.isSendRequestOK()) {
                    pullCallback.onException(new MQClientException("send request failed to " + addr + ". Request: " + request, responseFuture.getCause()));
                } else if (responseFuture.isTimeout()) {
                    pullCallback.onException(new MQClientException("wait response from " + addr + " timeout :" + responseFuture.getTimeoutMillis() + "ms" + ". Request: " + request,
                        responseFuture.getCause()));
                } else {
                    pullCallback.onException(new MQClientException("unknown reason. addr: " + addr + ", timeoutMillis: " + timeoutMillis + ". Request: " + request, responseFuture.getCause()));
                }
            }
        }
    });
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:32,代码来源:MQClientAPIImpl.java

示例6: pullMessageAsync

import org.apache.rocketmq.client.consumer.PullCallback; //导入依赖的package包/类
private void pullMessageAsync(//
    final String addr, // 1
    final RemotingCommand request, //
    final long timeoutMillis, //
    final PullCallback pullCallback//
) throws RemotingException, InterruptedException {
    this.remotingClient.invokeAsync(addr, request, timeoutMillis, new InvokeCallback() {
        @Override
        public void operationComplete(ResponseFuture responseFuture) {
            RemotingCommand response = responseFuture.getResponseCommand();
            if (response != null) {
                try {
                    PullResult pullResult = MQClientAPIImpl.this.processPullResponse(response);
                    assert pullResult != null;
                    pullCallback.onSuccess(pullResult);
                } catch (Exception e) {
                    pullCallback.onException(e);
                }
            } else {
                if (!responseFuture.isSendRequestOK()) {
                    pullCallback.onException(new MQClientException("send request failed", responseFuture.getCause()));
                } else if (responseFuture.isTimeout()) {
                    pullCallback.onException(new MQClientException("wait response timeout " + responseFuture.getTimeoutMillis() + "ms",
                        responseFuture.getCause()));
                } else {
                    pullCallback.onException(new MQClientException("unknow reseaon", responseFuture.getCause()));
                }
            }
        }
    });
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:32,代码来源:MQClientAPIImpl.java

示例7: pullMessageAsync

import org.apache.rocketmq.client.consumer.PullCallback; //导入依赖的package包/类
private void pullMessageAsync(
    final String addr,
    final RemotingCommand request,
    final long timeoutMillis,
    final PullCallback pullCallback
) throws RemotingException, InterruptedException {
    this.remotingClient.invokeAsync(addr, request, timeoutMillis, new InvokeCallback() {
        @Override
        public void operationComplete(ResponseFuture responseFuture) {
            RemotingCommand response = responseFuture.getResponseCommand();
            if (response != null) {
                try {
                    PullResult pullResult = MQClientAPIImpl.this.processPullResponse(response);
                    assert pullResult != null;
                    pullCallback.onSuccess(pullResult);
                } catch (Exception e) {
                    pullCallback.onException(e);
                }
            } else {
                if (!responseFuture.isSendRequestOK()) {
                    pullCallback.onException(new MQClientException("send request failed to " + addr + ". Request: " + request, responseFuture.getCause()));
                } else if (responseFuture.isTimeout()) {
                    pullCallback.onException(new MQClientException("wait response from " + addr + " timeout :" + responseFuture.getTimeoutMillis() + "ms" + ". Request: " + request,
                        responseFuture.getCause()));
                } else {
                    pullCallback.onException(new MQClientException("unknown reason. addr: " + addr + ", timeoutMillis: " + timeoutMillis + ". Request: " + request, responseFuture.getCause()));
                }
            }
        }
    });
}
 
开发者ID:apache,项目名称:rocketmq,代码行数:32,代码来源:MQClientAPIImpl.java

示例8: pull

import org.apache.rocketmq.client.consumer.PullCallback; //导入依赖的package包/类
public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
    throws MQClientException, RemotingException, InterruptedException {
    pull(mq, subExpression, offset, maxNums, pullCallback, this.defaultMQPullConsumer.getConsumerPullTimeoutMillis());
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:5,代码来源:DefaultMQPullConsumerImpl.java

示例9: pullBlockIfNotFound

import org.apache.rocketmq.client.consumer.PullCallback; //导入依赖的package包/类
public void pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums,
    PullCallback pullCallback)
    throws MQClientException, RemotingException, InterruptedException {
    this.pullAsyncImpl(mq, subExpression, offset, maxNums, pullCallback, true,
        this.getDefaultMQPullConsumer().getConsumerPullTimeoutMillis());
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:7,代码来源:DefaultMQPullConsumerImpl.java

示例10: pullBlockIfNotFound

import org.apache.rocketmq.client.consumer.PullCallback; //导入依赖的package包/类
public void pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
    throws MQClientException, RemotingException, InterruptedException {
    this.pullAsyncImpl(mq, subExpression, offset, maxNums, pullCallback, true,
        this.getDefaultMQPullConsumer().getConsumerPullTimeoutMillis());
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:6,代码来源:DefaultMQPullConsumerImpl.java

示例11: pullKernelImpl

import org.apache.rocketmq.client.consumer.PullCallback; //导入依赖的package包/类
public PullResult pullKernelImpl(
    final MessageQueue mq,
    final String subExpression,
    final long subVersion,
    final long offset,
    final int maxNums,
    final int sysFlag,
    final long commitOffset,
    final long brokerSuspendMaxTimeMillis,
    final long timeoutMillis,
    final CommunicationMode communicationMode,
    final PullCallback pullCallback
) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
    FindBrokerResult findBrokerResult =
        this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(),
            this.recalculatePullFromWhichNode(mq), false);
    if (null == findBrokerResult) {
        this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
        findBrokerResult =
            this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(),
                this.recalculatePullFromWhichNode(mq), false);
    }

    if (findBrokerResult != null) {
        int sysFlagInner = sysFlag;

        //如果获取回来的broker是slave的话,则无需commit
        if (findBrokerResult.isSlave()) {
            sysFlagInner = PullSysFlag.clearCommitOffsetFlag(sysFlagInner);
        }

        PullMessageRequestHeader requestHeader = new PullMessageRequestHeader();
        requestHeader.setConsumerGroup(this.consumerGroup);
        requestHeader.setTopic(mq.getTopic());
        requestHeader.setQueueId(mq.getQueueId());
        requestHeader.setQueueOffset(offset);
        requestHeader.setMaxMsgNums(maxNums);
        requestHeader.setSysFlag(sysFlagInner);
        requestHeader.setCommitOffset(commitOffset);
        requestHeader.setSuspendTimeoutMillis(brokerSuspendMaxTimeMillis);
        requestHeader.setSubscription(subExpression);
        requestHeader.setSubVersion(subVersion);

        String brokerAddr = findBrokerResult.getBrokerAddr();
        if (PullSysFlag.hasClassFilterFlag(sysFlagInner)) {
            brokerAddr = computPullFromWhichFilterServer(mq.getTopic(), brokerAddr);
        }

        PullResult pullResult = this.mQClientFactory.getMQClientAPIImpl().pullMessage(
            brokerAddr,
            requestHeader,
            timeoutMillis,
            communicationMode,
            pullCallback);

        return pullResult;
    }

    throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:61,代码来源:PullAPIWrapper.java


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