Search in sources :

Example 1 with PullStatus

use of org.apache.rocketmq.client.consumer.PullStatus in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class MQClientAPIImpl method processPullResponse.

private PullResult processPullResponse(final RemotingCommand response) throws MQBrokerException, RemotingCommandException {
    PullStatus pullStatus = PullStatus.NO_NEW_MSG;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            pullStatus = PullStatus.FOUND;
            break;
        case ResponseCode.PULL_NOT_FOUND:
            pullStatus = PullStatus.NO_NEW_MSG;
            break;
        case ResponseCode.PULL_RETRY_IMMEDIATELY:
            pullStatus = PullStatus.NO_MATCHED_MSG;
            break;
        case ResponseCode.PULL_OFFSET_MOVED:
            pullStatus = PullStatus.OFFSET_ILLEGAL;
            break;
        default:
            throw new MQBrokerException(response.getCode(), response.getRemark());
    }
    PullMessageResponseHeader responseHeader = (PullMessageResponseHeader) response.decodeCommandCustomHeader(PullMessageResponseHeader.class);
    return new PullResultExt(pullStatus, responseHeader.getNextBeginOffset(), responseHeader.getMinOffset(), responseHeader.getMaxOffset(), null, responseHeader.getSuggestWhichBrokerId(), response.getBody());
}
Also used : MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) PullResultExt(org.apache.rocketmq.client.impl.consumer.PullResultExt) PullStatus(org.apache.rocketmq.client.consumer.PullStatus) PullMessageResponseHeader(org.apache.rocketmq.common.protocol.header.PullMessageResponseHeader)

Example 2 with PullStatus

use of org.apache.rocketmq.client.consumer.PullStatus in project rocketmq by apache.

the class MQClientAPIImpl method processPullResponse.

private PullResult processPullResponse(final RemotingCommand response) throws MQBrokerException, RemotingCommandException {
    PullStatus pullStatus = PullStatus.NO_NEW_MSG;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            pullStatus = PullStatus.FOUND;
            break;
        case ResponseCode.PULL_NOT_FOUND:
            pullStatus = PullStatus.NO_NEW_MSG;
            break;
        case ResponseCode.PULL_RETRY_IMMEDIATELY:
            pullStatus = PullStatus.NO_MATCHED_MSG;
            break;
        case ResponseCode.PULL_OFFSET_MOVED:
            pullStatus = PullStatus.OFFSET_ILLEGAL;
            break;
        default:
            throw new MQBrokerException(response.getCode(), response.getRemark());
    }
    PullMessageResponseHeader responseHeader = (PullMessageResponseHeader) response.decodeCommandCustomHeader(PullMessageResponseHeader.class);
    return new PullResultExt(pullStatus, responseHeader.getNextBeginOffset(), responseHeader.getMinOffset(), responseHeader.getMaxOffset(), null, responseHeader.getSuggestWhichBrokerId(), response.getBody());
}
Also used : MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) PullResultExt(org.apache.rocketmq.client.impl.consumer.PullResultExt) PullStatus(org.apache.rocketmq.client.consumer.PullStatus) PullMessageResponseHeader(org.apache.rocketmq.common.protocol.header.PullMessageResponseHeader)

Aggregations

PullStatus (org.apache.rocketmq.client.consumer.PullStatus)2 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)2 PullResultExt (org.apache.rocketmq.client.impl.consumer.PullResultExt)2 PullMessageResponseHeader (org.apache.rocketmq.common.protocol.header.PullMessageResponseHeader)2