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


Java MQBrokerException类代码示例

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


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

示例1: reportConsumerRunningInfo

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
public void reportConsumerRunningInfo(final String consumerGroup) throws InterruptedException,
        MQBrokerException, RemotingException, MQClientException {
    ConsumerConnection cc = defaultMQAdminExt.examineConsumerConnectionInfo(consumerGroup);
    TreeMap<String, ConsumerRunningInfo> infoMap = new TreeMap<String, ConsumerRunningInfo>();
    for (Connection c : cc.getConnectionSet()) {
        String clientId = c.getClientId();
        if (c.getVersion() < MQVersion.Version.V3_1_8_SNAPSHOT.ordinal()) {
            continue;
        }

        try {
            ConsumerRunningInfo info =
                    defaultMQAdminExt.getConsumerRunningInfo(consumerGroup, clientId, false);
            infoMap.put(clientId, info);
        }
        catch (Exception e) {
        }
    }

    if (!infoMap.isEmpty()) {
        this.monitorListener.reportConsumerRunningInfo(infoMap);
    }
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:24,代码来源:MonitorService.java

示例2: resetOffsetConsumeOffset

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
private RollbackStats resetOffsetConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue queue, OffsetWrapper offsetWrapper,
        long timestamp, boolean force) throws RemotingException, InterruptedException, MQBrokerException {
    long resetOffset =
            this.mqClientInstance.getMQClientAPIImpl().searchOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timestamp,
                timeoutMillis);
    RollbackStats rollbackStats = new RollbackStats();
    rollbackStats.setBrokerName(queue.getBrokerName());
    rollbackStats.setQueueId(queue.getQueueId());
    rollbackStats.setBrokerOffset(offsetWrapper.getBrokerOffset());
    rollbackStats.setConsumerOffset(offsetWrapper.getConsumerOffset());
    rollbackStats.setTimestampOffset(resetOffset);
    rollbackStats.setRollbackOffset(offsetWrapper.getConsumerOffset());

    if (force || resetOffset <= offsetWrapper.getConsumerOffset()) {
        rollbackStats.setRollbackOffset(resetOffset);
        UpdateConsumerOffsetRequestHeader requestHeader = new UpdateConsumerOffsetRequestHeader();
        requestHeader.setConsumerGroup(consumeGroup);
        requestHeader.setTopic(queue.getTopic());
        requestHeader.setQueueId(queue.getQueueId());
        requestHeader.setCommitOffset(resetOffset);
        this.mqClientInstance.getMQClientAPIImpl().updateConsumerOffset(brokerAddr, requestHeader, timeoutMillis);
    }
    return rollbackStats;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:25,代码来源:DefaultMQAdminExtImpl.java

示例3: getAllDelayOffset

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
public String getAllDelayOffset(final String addr) throws InterruptedException, RemotingTimeoutException,
        RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.GET_ALL_DELAY_OFFSET, null);
    RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
    assert response != null;
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        return new String(response.getBody());
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:17,代码来源:BrokerOuterAPI.java

示例4: updateConsumeOffsetToBroker

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
/**
 * Update the Consumer Offset, once the Master is off, updated to Slave,
 * here need to be optimized.
 */
private void updateConsumeOffsetToBroker(MessageQueue mq, long offset) throws RemotingException,
        MQBrokerException, InterruptedException, MQClientException {
    FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
    if (null == findBrokerResult) {
        // TODO Here may be heavily overhead for Name Server,need tuning
        this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
        findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
    }

    if (findBrokerResult != null) {
        UpdateConsumerOffsetRequestHeader requestHeader = new UpdateConsumerOffsetRequestHeader();
        requestHeader.setTopic(mq.getTopic());
        requestHeader.setConsumerGroup(this.groupName);
        requestHeader.setQueueId(mq.getQueueId());
        requestHeader.setCommitOffset(offset);

        this.mQClientFactory.getMQClientAPIImpl().updateConsumerOffsetOneway(
                findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
    } else {
        throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
    }
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:27,代码来源:RemoteBrokerOffsetStore.java

示例5: fetchConsumeOffsetFromBroker

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
private long fetchConsumeOffsetFromBroker(MessageQueue mq) throws RemotingException, MQBrokerException,
        InterruptedException, MQClientException {
    FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
    if (null == findBrokerResult) {
        // TODO Here may be heavily overhead for Name Server,need tuning
        this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
        findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
    }

    if (findBrokerResult != null) {
        QueryConsumerOffsetRequestHeader requestHeader = new QueryConsumerOffsetRequestHeader();
        requestHeader.setTopic(mq.getTopic());
        requestHeader.setConsumerGroup(this.groupName);
        requestHeader.setQueueId(mq.getQueueId());

        return this.mQClientFactory.getMQClientAPIImpl().queryConsumerOffset(
                findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
    } else {
        throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
    }
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:22,代码来源:RemoteBrokerOffsetStore.java

示例6: examineTopicStats

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
@Override
public TopicStatsTable examineTopicStats(String topic) throws RemotingException, MQClientException, InterruptedException,
        MQBrokerException {
    TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
    TopicStatsTable topicStatsTable = new TopicStatsTable();

    for (BrokerData bd : topicRouteData.getBrokerDatas()) {
        String addr = bd.selectBrokerAddr();
        if (addr != null) {
            TopicStatsTable tst = this.mqClientInstance.getMQClientAPIImpl().getTopicStatsInfo(addr, topic, timeoutMillis);
            topicStatsTable.getOffsetTable().putAll(tst.getOffsetTable());
        }
    }

    if (topicStatsTable.getOffsetTable().isEmpty()) {
        throw new MQClientException("Not found the topic stats info", null);
    }

    return topicStatsTable;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:21,代码来源:DefaultMQAdminExtImpl.java

示例7: createSubscriptionGroup

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
public void createSubscriptionGroup(final String addr, final SubscriptionGroupConfig config, final long timeoutMillis)
        throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP, null);

    byte[] body = RemotingSerializable.encode(config);
    request.setBody(body);

    RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        return;
    }
    default:
        break;
    }

    throw new MQClientException(response.getCode(), response.getRemark());

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

示例8: createTopic

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
public void createTopic(final String addr, final String defaultTopic, final TopicConfig topicConfig, final long timeoutMillis)
        throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    CreateTopicRequestHeader requestHeader = new CreateTopicRequestHeader();
    requestHeader.setTopic(topicConfig.getTopicName());
    requestHeader.setDefaultTopic(defaultTopic);
    requestHeader.setReadQueueNums(topicConfig.getReadQueueNums());
    requestHeader.setWriteQueueNums(topicConfig.getWriteQueueNums());
    requestHeader.setPerm(topicConfig.getPerm());
    requestHeader.setTopicFilterType(topicConfig.getTopicFilterType().name());
    requestHeader.setTopicSysFlag(topicConfig.getTopicSysFlag());
    requestHeader.setOrder(topicConfig.isOrder());

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

    RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        return;
    }
    default:
        break;
    }

    throw new MQClientException(response.getCode(), response.getRemark());
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:27,代码来源:MQClientAPIImpl.java

示例9: resetOffsetByTimestamp

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
public Map<MessageQueue, Long> resetOffsetByTimestamp(String topic, String group, long timestamp, boolean isForce, boolean isC)
        throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
    List<BrokerData> brokerDatas = topicRouteData.getBrokerDatas();
    Map<MessageQueue, Long> allOffsetTable = new HashMap<MessageQueue, Long>();
    if (brokerDatas != null) {
        for (BrokerData brokerData : brokerDatas) {
            String addr = brokerData.selectBrokerAddr();
            if (addr != null) {
                Map<MessageQueue, Long> offsetTable =
                        this.mqClientInstance.getMQClientAPIImpl().invokeBrokerToResetOffset(addr, topic, group, timestamp, isForce,
                            timeoutMillis, isC);
                if (offsetTable != null) {
                    allOffsetTable.putAll(offsetTable);
                }
            }
        }
    }
    return allOffsetTable;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:21,代码来源:DefaultMQAdminExtImpl.java

示例10: pullMessage

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的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:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:26,代码来源:MQClientAPIImpl.java

示例11: processPullResponse

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
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());
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:27,代码来源:MQClientAPIImpl.java

示例12: viewMessage

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
public MessageExt viewMessage(final String addr, final long phyoffset, final long timeoutMillis) throws RemotingException,
        MQBrokerException, InterruptedException {
    ViewMessageRequestHeader requestHeader = new ViewMessageRequestHeader();
    requestHeader.setOffset(phyoffset);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.VIEW_MESSAGE_BY_ID, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        ByteBuffer byteBuffer = ByteBuffer.wrap(response.getBody());
        MessageExt messageExt = MessageDecoder.decode(byteBuffer);
        return messageExt;
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:21,代码来源:MQClientAPIImpl.java

示例13: getEarliestMsgStoretime

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
public long getEarliestMsgStoretime(final String addr, final String topic, final int queueId, final long timeoutMillis)
        throws RemotingException, MQBrokerException, InterruptedException {
    GetEarliestMsgStoretimeRequestHeader requestHeader = new GetEarliestMsgStoretimeRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setQueueId(queueId);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_EARLIEST_MSG_STORETIME, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        GetEarliestMsgStoretimeResponseHeader responseHeader =
                (GetEarliestMsgStoretimeResponseHeader) response.decodeCommandCustomHeader(GetEarliestMsgStoretimeResponseHeader.class);

        return responseHeader.getTimestamp();
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:23,代码来源:MQClientAPIImpl.java

示例14: sendHearbeat

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
public void sendHearbeat(//
        final String addr,//
        final HeartbeatData heartbeatData,//
        final long timeoutMillis//
) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.HEART_BEAT, null);

    request.setBody(heartbeatData.encode());
    RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        return;
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:21,代码来源:MQClientAPIImpl.java

示例15: unregisterClient

import com.alibaba.rocketmq.client.exception.MQBrokerException; //导入依赖的package包/类
public void unregisterClient(//
        final String addr,//
        final String clientID,//
        final String producerGroup,//
        final String consumerGroup,//
        final long timeoutMillis//
) throws RemotingException, MQBrokerException, InterruptedException {
    final UnregisterClientRequestHeader requestHeader = new UnregisterClientRequestHeader();
    requestHeader.setClientID(clientID);
    requestHeader.setProducerGroup(producerGroup);
    requestHeader.setConsumerGroup(consumerGroup);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNREGISTER_CLIENT, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        return;
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:26,代码来源:MQClientAPIImpl.java


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