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


Java RemotingCommand.decodeCommandCustomHeader方法代码示例

本文整理汇总了Java中org.apache.rocketmq.remoting.protocol.RemotingCommand.decodeCommandCustomHeader方法的典型用法代码示例。如果您正苦于以下问题:Java RemotingCommand.decodeCommandCustomHeader方法的具体用法?Java RemotingCommand.decodeCommandCustomHeader怎么用?Java RemotingCommand.decodeCommandCustomHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.rocketmq.remoting.protocol.RemotingCommand的用法示例。


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

示例1: checkTransactionState

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public RemotingCommand checkTransactionState(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final CheckTransactionStateRequestHeader requestHeader =
        (CheckTransactionStateRequestHeader) request.decodeCommandCustomHeader(CheckTransactionStateRequestHeader.class);
    final ByteBuffer byteBuffer = ByteBuffer.wrap(request.getBody());
    final MessageExt messageExt = MessageDecoder.decode(byteBuffer);
    if (messageExt != null) {
        final String group = messageExt.getProperty(MessageConst.PROPERTY_PRODUCER_GROUP);
        if (group != null) {
            MQProducerInner producer = this.mqClientFactory.selectProducer(group);
            if (producer != null) {
                final String addr = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
                producer.checkTransactionState(addr, messageExt, requestHeader);
            } else {
                log.debug("checkTransactionState, pick producer by group[{}] failed", group);
            }
        } else {
            log.warn("checkTransactionState, pick producer group failed");
        }
    } else {
        log.warn("checkTransactionState, decode message failed");
    }

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

示例2: getKVListByNamespace

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
/**
 * 获取一个Namespace下的所有kv
 */
private RemotingCommand getKVListByNamespace(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetKVListByNamespaceRequestHeader requestHeader =
        (GetKVListByNamespaceRequestHeader) request.decodeCommandCustomHeader(GetKVListByNamespaceRequestHeader.class);

    byte[] jsonValue = this.namesrvController.getKvConfigManager().getKVListByNamespace(
        requestHeader.getNamespace());
    if (null != jsonValue) {
        response.setBody(jsonValue);
        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);
        return response;
    }

    response.setCode(ResponseCode.QUERY_NOT_FOUND);
    response.setRemark("No config item, Namespace: " + requestHeader.getNamespace());
    return response;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:22,代码来源:DefaultRequestProcessor.java

示例3: consumeMessageDirectly

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final ConsumeMessageDirectlyResultRequestHeader requestHeader =
        (ConsumeMessageDirectlyResultRequestHeader) request
            .decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);

    final MessageExt msg = MessageDecoder.decode(ByteBuffer.wrap(request.getBody()));

    ConsumeMessageDirectlyResult result =
        this.mqClientFactory.consumeMessageDirectly(msg, requestHeader.getConsumerGroup(), requestHeader.getBrokerName());

    if (null != result) {
        response.setCode(ResponseCode.SUCCESS);
        response.setBody(result.encode());
    } else {
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup()));
    }

    return response;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:22,代码来源:ClientRemotingProcessor.java

示例4: wipeWritePermOfBroker

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand wipeWritePermOfBroker(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(WipeWritePermOfBrokerResponseHeader.class);
    final WipeWritePermOfBrokerResponseHeader responseHeader = (WipeWritePermOfBrokerResponseHeader) response.readCustomHeader();
    final WipeWritePermOfBrokerRequestHeader requestHeader =
        (WipeWritePermOfBrokerRequestHeader) request.decodeCommandCustomHeader(WipeWritePermOfBrokerRequestHeader.class);

    int wipeTopicCnt = this.namesrvController.getRouteInfoManager().wipeWritePermOfBrokerByLock(requestHeader.getBrokerName());

    log.info("wipe write perm of broker[{}], client: {}, {}",
        requestHeader.getBrokerName(),
        RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
        wipeTopicCnt);

    responseHeader.setWipeTopicCount(wipeTopicCnt);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:19,代码来源:DefaultRequestProcessor.java

示例5: consumeMessageDirectly

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final ConsumeMessageDirectlyResultRequestHeader requestHeader = (ConsumeMessageDirectlyResultRequestHeader) request
        .decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);

    request.getExtFields().put("brokerName", this.brokerController.getBrokerConfig().getBrokerName());
    SelectMappedBufferResult selectMappedBufferResult = null;
    try {
        MessageId messageId = MessageDecoder.decodeMessageId(requestHeader.getMsgId());
        selectMappedBufferResult = this.brokerController.getMessageStore().selectOneMessageByOffset(messageId.getOffset());

        byte[] body = new byte[selectMappedBufferResult.getSize()];
        selectMappedBufferResult.getByteBuffer().get(body);
        request.setBody(body);
    } catch (UnknownHostException e) {
    } finally {
        if (selectMappedBufferResult != null) {
            selectMappedBufferResult.release();
        }
    }

    return this.callConsumer(RequestCode.CONSUME_MESSAGE_DIRECTLY, request, requestHeader.getConsumerGroup(),
        requestHeader.getClientId());
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:24,代码来源:AdminBrokerProcessor.java

示例6: getConsumerRunningInfo

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
/**

     */
    private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
        final GetConsumerRunningInfoRequestHeader requestHeader =
            (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);

        return this.callConsumer(RequestCode.GET_CONSUMER_RUNNING_INFO, request, requestHeader.getConsumerGroup(),
            requestHeader.getClientId());
    }
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:11,代码来源:AdminBrokerProcessor.java

示例7: notifyConsumerIdsChanged

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public RemotingCommand notifyConsumerIdsChanged(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    try {
        final NotifyConsumerIdsChangedRequestHeader requestHeader =
            (NotifyConsumerIdsChangedRequestHeader) request.decodeCommandCustomHeader(NotifyConsumerIdsChangedRequestHeader.class);
        log.info("receive broker's notification[{}], the consumer group: {} changed, rebalance immediately",
            RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
            requestHeader.getConsumerGroup());
        this.mqClientFactory.rebalanceImmediately();
    } catch (Exception e) {
        log.error("notifyConsumerIdsChanged exception", RemotingHelper.exceptionSimpleDesc(e));
    }
    return null;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:14,代码来源:ClientRemotingProcessor.java

示例8: deleteSubscriptionGroup

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand deleteSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    DeleteSubscriptionGroupRequestHeader requestHeader =
        (DeleteSubscriptionGroupRequestHeader) request.decodeCommandCustomHeader(DeleteSubscriptionGroupRequestHeader.class);

    log.info("deleteSubscriptionGroup called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));

    this.brokerController.getSubscriptionGroupManager().deleteSubscriptionGroupConfig(requestHeader.getGroupName());

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:14,代码来源:AdminBrokerProcessor.java

示例9: resetOffset

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public RemotingCommand resetOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final ResetOffsetRequestHeader requestHeader =
        (ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
    log.info("invoke reset offset operation from broker. brokerAddr={}, topic={}, group={}, timestamp={}",
            RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
            requestHeader.getTimestamp());
    Map<MessageQueue, Long> offsetTable = new HashMap<MessageQueue, Long>();
    if (request.getBody() != null) {
        ResetOffsetBody body = ResetOffsetBody.decode(request.getBody(), ResetOffsetBody.class);
        offsetTable = body.getOffsetTable();
    }
    this.mqClientFactory.resetOffset(requestHeader.getTopic(), requestHeader.getGroup(), offsetTable);
    return null;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:15,代码来源:ClientRemotingProcessor.java

示例10: registerFilterServer

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand registerFilterServer(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterFilterServerResponseHeader.class);
    final RegisterFilterServerResponseHeader responseHeader = (RegisterFilterServerResponseHeader) response.readCustomHeader();
    final RegisterFilterServerRequestHeader requestHeader =
        (RegisterFilterServerRequestHeader) request.decodeCommandCustomHeader(RegisterFilterServerRequestHeader.class);

    this.brokerController.getFilterServerManager().registerFilterServer(ctx.channel(), requestHeader.getFilterServerAddr());

    responseHeader.setBrokerId(this.brokerController.getBrokerConfig().getBrokerId());
    responseHeader.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:16,代码来源:AdminBrokerProcessor.java

示例11: deleteKVConfig

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public RemotingCommand deleteKVConfig(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final DeleteKVConfigRequestHeader requestHeader =
        (DeleteKVConfigRequestHeader) request.decodeCommandCustomHeader(DeleteKVConfigRequestHeader.class);

    this.namesrvController.getKvConfigManager().deleteKVConfig(
        requestHeader.getNamespace(),
        requestHeader.getKey()
    );

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:15,代码来源:DefaultRequestProcessor.java

示例12: getMaxOffset

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand getMaxOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(GetMaxOffsetResponseHeader.class);
    final GetMaxOffsetResponseHeader responseHeader = (GetMaxOffsetResponseHeader) response.readCustomHeader();
    final GetMaxOffsetRequestHeader requestHeader =
        (GetMaxOffsetRequestHeader) request.decodeCommandCustomHeader(GetMaxOffsetRequestHeader.class);

    long offset = this.brokerController.getMessageStore().getMaxOffsetInQueue(requestHeader.getTopic(), requestHeader.getQueueId());

    responseHeader.setOffset(offset);

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:15,代码来源:AdminBrokerProcessor.java

示例13: getProducerConnectionList

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand getProducerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetProducerConnectionListRequestHeader requestHeader =
        (GetProducerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetProducerConnectionListRequestHeader.class);

    ProducerConnection bodydata = new ProducerConnection();
    HashMap<Channel, ClientChannelInfo> channelInfoHashMap =
        this.brokerController.getProducerManager().getGroupChannelTable().get(requestHeader.getProducerGroup());
    if (channelInfoHashMap != null) {
        Iterator<Map.Entry<Channel, ClientChannelInfo>> it = channelInfoHashMap.entrySet().iterator();
        while (it.hasNext()) {
            ClientChannelInfo info = it.next().getValue();
            Connection connection = new Connection();
            connection.setClientId(info.getClientId());
            connection.setLanguage(info.getLanguage());
            connection.setVersion(info.getVersion());
            connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel()));

            bodydata.getConnectionSet().add(connection);
        }

        byte[] body = bodydata.encode();
        response.setBody(body);
        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);
        return response;
    }

    response.setCode(ResponseCode.SYSTEM_ERROR);
    response.setRemark("the producer group[" + requestHeader.getProducerGroup() + "] not exist");
    return response;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:33,代码来源:AdminBrokerProcessor.java

示例14: getTopicsByCluster

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand getTopicsByCluster(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetTopicsByClusterRequestHeader requestHeader =
        (GetTopicsByClusterRequestHeader) request.decodeCommandCustomHeader(GetTopicsByClusterRequestHeader.class);

    byte[] body = this.namesrvController.getRouteInfoManager().getTopicsByCluster(requestHeader.getCluster());

    response.setBody(body);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:13,代码来源:DefaultRequestProcessor.java

示例15: cloneGroupOffset

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand cloneGroupOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    CloneGroupOffsetRequestHeader requestHeader =
        (CloneGroupOffsetRequestHeader) request.decodeCommandCustomHeader(CloneGroupOffsetRequestHeader.class);

    Set<String> topics;
    if (UtilAll.isBlank(requestHeader.getTopic())) {
        topics = this.brokerController.getConsumerOffsetManager().whichTopicByConsumer(requestHeader.getSrcGroup());
    } else {
        topics = new HashSet<String>();
        topics.add(requestHeader.getTopic());
    }

    for (String topic : topics) {
        TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
        if (null == topicConfig) {
            log.warn("[cloneGroupOffset], topic config not exist, {}", topic);
            continue;
        }

        /**

         */
        if (!requestHeader.isOffline()) {

            SubscriptionData findSubscriptionData =
                this.brokerController.getConsumerManager().findSubscriptionData(requestHeader.getSrcGroup(), topic);
            if (this.brokerController.getConsumerManager().findSubscriptionDataCount(requestHeader.getSrcGroup()) > 0
                && findSubscriptionData == null) {
                log.warn("[cloneGroupOffset], the consumer group[{}], topic[{}] not exist", requestHeader.getSrcGroup(), topic);
                continue;
            }
        }

        this.brokerController.getConsumerOffsetManager().cloneOffset(requestHeader.getSrcGroup(), requestHeader.getDestGroup(),
            requestHeader.getTopic());
    }

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:43,代码来源:AdminBrokerProcessor.java


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