當前位置: 首頁>>代碼示例>>Java>>正文


Java RemotingCommand.markResponseType方法代碼示例

本文整理匯總了Java中org.apache.rocketmq.remoting.protocol.RemotingCommand.markResponseType方法的典型用法代碼示例。如果您正苦於以下問題:Java RemotingCommand.markResponseType方法的具體用法?Java RemotingCommand.markResponseType怎麽用?Java RemotingCommand.markResponseType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.rocketmq.remoting.protocol.RemotingCommand的用法示例。


在下文中一共展示了RemotingCommand.markResponseType方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: executeRequestWhenWakeup

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //導入方法依賴的package包/類
public void executeRequestWhenWakeup(final Channel channel, final RemotingCommand request) throws RemotingCommandException {
    Runnable run = new Runnable() {
        @Override
        public void run() {
            try {
                final RemotingCommand response = PullMessageProcessor.this.processRequest(channel, request, false);

                if (response != null) {
                    response.setOpaque(request.getOpaque());
                    response.markResponseType();
                    try {
                        channel.writeAndFlush(response).addListener(new ChannelFutureListener() {
                            @Override
                            public void operationComplete(ChannelFuture future) throws Exception {
                                if (!future.isSuccess()) {
                                    LOG.error("ProcessRequestWrapper response to {} failed", future.channel().remoteAddress(), future.cause());
                                    LOG.error(request.toString());
                                    LOG.error(response.toString());
                                }
                            }
                        });
                    } catch (Throwable e) {
                        LOG.error("ProcessRequestWrapper process request over, but response failed", e);
                        LOG.error(request.toString());
                        LOG.error(response.toString());
                    }
                }
            } catch (RemotingCommandException e1) {
                LOG.error("ExecuteRequestWhenWakeup run", e1);
            }
        }
    };
    this.brokerController.getPullMessageExecutor().submit(new RequestTask(run, channel, request));
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:35,代碼來源:PullMessageProcessor.java

示例2: updateAndCreateTopic

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //導入方法依賴的package包/類
private RemotingCommand updateAndCreateTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final CreateTopicRequestHeader requestHeader =
        (CreateTopicRequestHeader) request.decodeCommandCustomHeader(CreateTopicRequestHeader.class);
    log.info("updateAndCreateTopic called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));

    if (requestHeader.getTopic().equals(this.brokerController.getBrokerConfig().getBrokerClusterName())) {
        String errorMsg = "the topic[" + requestHeader.getTopic() + "] is conflict with system reserved words.";
        log.warn(errorMsg);
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark(errorMsg);
        return response;
    }

    try {
        response.setCode(ResponseCode.SUCCESS);
        response.setOpaque(request.getOpaque());
        response.markResponseType();
        response.setRemark(null);
        ctx.writeAndFlush(response);
    } catch (Exception e) {
        log.error("Failed to produce a proper response", e);
    }

    TopicConfig topicConfig = new TopicConfig(requestHeader.getTopic());
    topicConfig.setReadQueueNums(requestHeader.getReadQueueNums());
    topicConfig.setWriteQueueNums(requestHeader.getWriteQueueNums());
    topicConfig.setTopicFilterType(requestHeader.getTopicFilterTypeEnum());
    topicConfig.setPerm(requestHeader.getPerm());
    topicConfig.setTopicSysFlag(requestHeader.getTopicSysFlag() == null ? 0 : requestHeader.getTopicSysFlag());

    this.brokerController.getTopicConfigManager().updateTopicConfig(topicConfig);
    this.brokerController.registerBrokerAll(false, true);

    return null;
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:37,代碼來源:AdminBrokerProcessor.java

示例3: updateAndCreateTopic

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //導入方法依賴的package包/類
private RemotingCommand updateAndCreateTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final CreateTopicRequestHeader requestHeader =
        (CreateTopicRequestHeader) request.decodeCommandCustomHeader(CreateTopicRequestHeader.class);
    log.info("updateAndCreateTopic called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));

    if (requestHeader.getTopic().equals(this.brokerController.getBrokerConfig().getBrokerClusterName())) {
        String errorMsg = "the topic[" + requestHeader.getTopic() + "] is conflict with system reserved words.";
        log.warn(errorMsg);
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark(errorMsg);
        return response;
    }

    try {
        response.setCode(ResponseCode.SUCCESS);
        response.setOpaque(request.getOpaque());
        response.markResponseType();
        response.setRemark(null);
        ctx.writeAndFlush(response);
    } catch (Exception e) {
    }

    TopicConfig topicConfig = new TopicConfig(requestHeader.getTopic());
    topicConfig.setReadQueueNums(requestHeader.getReadQueueNums());
    topicConfig.setWriteQueueNums(requestHeader.getWriteQueueNums());
    topicConfig.setTopicFilterType(requestHeader.getTopicFilterTypeEnum());
    topicConfig.setPerm(requestHeader.getPerm());
    topicConfig.setTopicSysFlag(requestHeader.getTopicSysFlag() == null ? 0 : requestHeader.getTopicSysFlag());

    this.brokerController.getTopicConfigManager().updateTopicConfig(topicConfig);
    this.brokerController.registerBrokerAll(false, true);
    return null;
}
 
開發者ID:lyy4j,項目名稱:rmq4note,代碼行數:35,代碼來源:AdminBrokerProcessor.java


注:本文中的org.apache.rocketmq.remoting.protocol.RemotingCommand.markResponseType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。