當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。