com.alibaba.rocketmq.common.protocol.RequestCode Java Examples
The following examples show how to use
com.alibaba.rocketmq.common.protocol.RequestCode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultRequestProcessor.java From rocketmq with Apache License 2.0 | 6 votes |
@Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws Exception { if (log.isDebugEnabled()) { log.debug("receive request, {} {} {}",// request.getCode(), // RemotingHelper.parseChannelRemoteAddr(ctx.channel()), // request); } switch (request.getCode()) { case RequestCode.REGISTER_MESSAGE_FILTER_CLASS: return registerMessageFilterClass(ctx, request); case RequestCode.PULL_MESSAGE: return pullMessageForward(ctx, request); } return null; }
Example #2
Source File: MQClientAPIImpl.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 6 votes |
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic, final long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException { GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader(); requestHeader.setTopic(topic); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader); RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class); return topicStatsTable; } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #3
Source File: MQAdminExtImpl.java From rocket-console with Apache License 2.0 | 6 votes |
@Override public TopicConfig examineTopicConfig(String addr, String topic) { RemotingClient remotingClient = MQAdminInstance.threadLocalRemotingClient(); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null); RemotingCommand response = null; try { response = remotingClient.invokeSync(addr, request, 3000); } catch (Exception err) { throw Throwables.propagate(err); } switch (response.getCode()) { case ResponseCode.SUCCESS: { TopicConfigSerializeWrapper topicConfigSerializeWrapper = decode(response.getBody(), TopicConfigSerializeWrapper.class); return topicConfigSerializeWrapper.getTopicConfigTable().get(topic); } default: throw Throwables.propagate(new MQBrokerException(response.getCode(), response.getRemark())); } }
Example #4
Source File: ClientRemotingProcessor.java From rocketmq with Apache License 2.0 | 6 votes |
@Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { switch (request.getCode()) { case RequestCode.CHECK_TRANSACTION_STATE: return this.checkTransactionState(ctx, request); case RequestCode.NOTIFY_CONSUMER_IDS_CHANGED: return this.notifyConsumerIdsChanged(ctx, request); case RequestCode.RESET_CONSUMER_CLIENT_OFFSET: return this.resetOffset(ctx, request); case RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT: return this.getConsumeStatus(ctx, request); case RequestCode.GET_CONSUMER_RUNNING_INFO: return this.getConsumerRunningInfo(ctx, request); case RequestCode.CONSUME_MESSAGE_DIRECTLY: return this.consumeMessageDirectly(ctx, request); default: break; } return null; }
Example #5
Source File: MQClientAPIImpl.java From rocketmq with Apache License 2.0 | 6 votes |
public MQClientAPIImpl(final NettyClientConfig nettyClientConfig, final ClientRemotingProcessor clientRemotingProcessor, RPCHook rpcHook, final ClientConfig clientConfig) { this.clientConfig = clientConfig; topAddressing = new TopAddressing(MixAll.WS_ADDR, clientConfig.getUnitName()); this.remotingClient = new NettyRemotingClient(nettyClientConfig, null); this.clientRemotingProcessor = clientRemotingProcessor; this.remotingClient.registerRPCHook(rpcHook); this.remotingClient.registerProcessor(RequestCode.CHECK_TRANSACTION_STATE, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_RUNNING_INFO, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.CONSUME_MESSAGE_DIRECTLY, this.clientRemotingProcessor, null); }
Example #6
Source File: MQClientAPIImpl.java From rocketmq with Apache License 2.0 | 6 votes |
public Set<MessageQueue> lockBatchMQ(// final String addr, // final LockBatchRequestBody requestBody, // final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.LOCK_BATCH_MQ, null); request.setBody(requestBody.encode()); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { LockBatchResponseBody responseBody = LockBatchResponseBody.decode(response.getBody(), LockBatchResponseBody.class); Set<MessageQueue> messageQueues = responseBody.getLockOKMQSet(); return messageQueues; } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #7
Source File: MQClientAPIImpl.java From rocketmq with Apache License 2.0 | 6 votes |
public void unlockBatchMQ(// final String addr, // final UnlockBatchRequestBody requestBody, // final long timeoutMillis, // final boolean oneway// ) throws RemotingException, MQBrokerException, InterruptedException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNLOCK_BATCH_MQ, null); request.setBody(requestBody.encode()); if (oneway) { this.remotingClient.invokeOneway(addr, request, timeoutMillis); } else { RemotingCommand response = this.remotingClient .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { return; } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); } }
Example #8
Source File: MQClientAPIImpl.java From rocketmq with Apache License 2.0 | 6 votes |
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic, final long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException { GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader(); requestHeader.setTopic(topic); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class); return topicStatsTable; } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #9
Source File: MQClientAPIImpl.java From rocketmq with Apache License 2.0 | 6 votes |
public ConsumeStats getConsumeStats(final String addr, final String consumerGroup, final String topic, final long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException { GetConsumeStatsRequestHeader requestHeader = new GetConsumeStatsRequestHeader(); requestHeader.setConsumerGroup(consumerGroup); requestHeader.setTopic(topic); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUME_STATS, requestHeader); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { ConsumeStats consumeStats = ConsumeStats.decode(response.getBody(), ConsumeStats.class); return consumeStats; } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #10
Source File: MQClientAPIImpl.java From rocketmq with Apache License 2.0 | 6 votes |
public ProducerConnection getProducerConnectionList(final String addr, final String producerGroup, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { GetProducerConnectionListRequestHeader requestHeader = new GetProducerConnectionListRequestHeader(); requestHeader.setProducerGroup(producerGroup); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_PRODUCER_CONNECTION_LIST, requestHeader); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { return ProducerConnection.decode(response.getBody(), ProducerConnection.class); } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #11
Source File: MQClientAPIImpl.java From rocketmq with Apache License 2.0 | 6 votes |
public ConsumerConnection getConsumerConnectionList(final String addr, final String consumerGroup, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { GetConsumerConnectionListRequestHeader requestHeader = new GetConsumerConnectionListRequestHeader(); requestHeader.setConsumerGroup(consumerGroup); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_CONNECTION_LIST, requestHeader); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { ConsumerConnection consumerConnection = ConsumerConnection.decode(response.getBody(), ConsumerConnection.class); return consumerConnection; } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #12
Source File: MQClientAPIImpl.java From rocketmq with Apache License 2.0 | 6 votes |
public KVTable getBrokerRuntimeInfo(final String addr, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_RUNTIME_INFO, null); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { return KVTable.decode(response.getBody(), KVTable.class); } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #13
Source File: MQClientAPIImpl.java From rocketmq with Apache License 2.0 | 6 votes |
public void updateBrokerConfig(final String addr, final Properties properties, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException, UnsupportedEncodingException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_BROKER_CONFIG, null); String str = MixAll.properties2String(properties); if (str != null && str.length() > 0) { request.setBody(str.getBytes(MixAll.DEFAULT_CHARSET)); RemotingCommand response = this.remotingClient .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { return; } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); } }
Example #14
Source File: MQClientAPIImpl.java From rocketmq with Apache License 2.0 | 6 votes |
public GroupList queryTopicConsumeByWho(final String addr, final String topic, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { QueryTopicConsumeByWhoRequestHeader requestHeader = new QueryTopicConsumeByWhoRequestHeader(); requestHeader.setTopic(topic); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_TOPIC_CONSUME_BY_WHO, requestHeader); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { GroupList groupList = GroupList.decode(response.getBody(), GroupList.class); return groupList; } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #15
Source File: MQClientAPIImpl.java From rocketmq with Apache License 2.0 | 6 votes |
public List<QueueTimeSpan> queryConsumeTimeSpan(final String addr, final String topic, final String group, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { QueryConsumeTimeSpanRequestHeader requestHeader = new QueryConsumeTimeSpanRequestHeader(); requestHeader.setTopic(topic); requestHeader.setGroup(group); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUME_TIME_SPAN, requestHeader); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { QueryConsumeTimeSpanBody consumeTimeSpanBody = GroupList.decode(response.getBody(), QueryConsumeTimeSpanBody.class); return consumeTimeSpanBody.getConsumeTimeSpanSet(); } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #16
Source File: MQClientAPIImpl.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 6 votes |
public MQClientAPIImpl(final NettyClientConfig nettyClientConfig, final ClientRemotingProcessor clientRemotingProcessor, RPCHook rpcHook, final String unitName) { topAddressing = new TopAddressing(MixAll.WS_ADDR, unitName); this.remotingClient = new NettyRemotingClient(nettyClientConfig, null); this.clientRemotingProcessor = clientRemotingProcessor; this.remotingClient.registerRPCHook(rpcHook); /** * 这些RequestCode是Client要处理的, 也就是调用方向是broker-》 client */ this.remotingClient.registerProcessor(RequestCode.CHECK_TRANSACTION_STATE, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_RUNNING_INFO, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.CONSUME_MESSAGE_DIRECTLY, this.clientRemotingProcessor, null); }
Example #17
Source File: AdminBrokerProcessor.java From rocketmq with Apache License 2.0 | 6 votes |
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()); SelectMapedBufferResult selectMapedBufferResult = null; try { MessageId messageId = MessageDecoder.decodeMessageId(requestHeader.getMsgId()); selectMapedBufferResult = this.brokerController.getMessageStore().selectOneMessageByOffset(messageId.getOffset()); byte[] body = new byte[selectMapedBufferResult.getSize()]; selectMapedBufferResult.getByteBuffer().get(body); request.setBody(body); } catch (UnknownHostException e) { } finally { if (selectMapedBufferResult != null) { selectMapedBufferResult.release(); } } return this.callConsumer(RequestCode.CONSUME_MESSAGE_DIRECTLY, request, requestHeader.getConsumerGroup(), requestHeader.getClientId()); }
Example #18
Source File: ClientManageProcessor.java From rocketmq with Apache License 2.0 | 6 votes |
@Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { switch (request.getCode()) { case RequestCode.HEART_BEAT: return this.heartBeat(ctx, request); case RequestCode.UNREGISTER_CLIENT: return this.unregisterClient(ctx, request); case RequestCode.GET_CONSUMER_LIST_BY_GROUP: return this.getConsumerListByGroup(ctx, request); case RequestCode.UPDATE_CONSUMER_OFFSET: return this.updateConsumerOffset(ctx, request); case RequestCode.QUERY_CONSUMER_OFFSET: return this.queryConsumerOffset(ctx, request); default: break; } return null; }
Example #19
Source File: SendMessageProcessor.java From rocketmq with Apache License 2.0 | 6 votes |
@Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { SendMessageContext mqtraceContext = null; switch (request.getCode()) { case RequestCode.CONSUMER_SEND_MSG_BACK: return this.consumerSendMsgBack(ctx, request); default: SendMessageRequestHeader requestHeader = parseRequestHeader(request); if (requestHeader == null) { return null; } mqtraceContext = buildMsgContext(ctx, requestHeader); this.executeSendMessageHookBefore(ctx, request, mqtraceContext); final RemotingCommand response = this.sendMessage(ctx, request, mqtraceContext, requestHeader); this.executeSendMessageHookAfter(response, mqtraceContext); return response; } }
Example #20
Source File: Broker2Client.java From rocketmq with Apache License 2.0 | 6 votes |
public void notifyConsumerIdsChanged(// final Channel channel,// final String consumerGroup// ) { if (null == consumerGroup) { log.error("notifyConsumerIdsChanged consumerGroup is null"); return; } NotifyConsumerIdsChangedRequestHeader requestHeader = new NotifyConsumerIdsChangedRequestHeader(); requestHeader.setConsumerGroup(consumerGroup); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, requestHeader); try { this.brokerController.getRemotingServer().invokeOneway(channel, request, 10); } catch (Exception e) { log.error("notifyConsumerIdsChanged exception, " + consumerGroup, e); } }
Example #21
Source File: ClientRemotingProcessor.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
@Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { switch (request.getCode()) { case RequestCode.CHECK_TRANSACTION_STATE: return this.checkTransactionState(ctx, request); case RequestCode.NOTIFY_CONSUMER_IDS_CHANGED: return this.notifyConsumerIdsChanged(ctx, request); case RequestCode.RESET_CONSUMER_CLIENT_OFFSET: return this.resetOffset(ctx, request); case RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT: return this.getConsumeStatus(ctx, request); case RequestCode.GET_CONSUMER_RUNNING_INFO: return this.getConsumerRunningInfo(ctx, request); case RequestCode.CONSUME_MESSAGE_DIRECTLY: return this.consumeMessageDirectly(ctx, request); default: break; } return null; }
Example #22
Source File: MQClientAPIImpl.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
public MQClientAPIImpl(final NettyClientConfig nettyClientConfig, final ClientRemotingProcessor clientRemotingProcessor, RPCHook rpcHook) { this.remotingClient = new NettyRemotingClient(nettyClientConfig, null); this.clientRemotingProcessor = clientRemotingProcessor; this.remotingClient.registerRPCHook(rpcHook); this.remotingClient.registerProcessor(RequestCode.CHECK_TRANSACTION_STATE, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_RUNNING_INFO, this.clientRemotingProcessor, null); this.remotingClient.registerProcessor(RequestCode.CONSUME_MESSAGE_DIRECTLY, this.clientRemotingProcessor, null); }
Example #23
Source File: ClientManageProcessor.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
@Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { switch (request.getCode()) { case RequestCode.HEART_BEAT: return this.heartBeat(ctx, request); case RequestCode.UNREGISTER_CLIENT: return this.unregisterClient(ctx, request); case RequestCode.GET_CONSUMER_LIST_BY_GROUP: return this.getConsumerListByGroup(ctx, request); // 更新Consumer Offset case RequestCode.UPDATE_CONSUMER_OFFSET: return this.updateConsumerOffset(ctx, request); case RequestCode.QUERY_CONSUMER_OFFSET: return this.queryConsumerOffset(ctx, request); default: break; } return null; }
Example #24
Source File: MQClientAPIImpl.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
/** * 获取Broker运行时信息 * * @param addr * @param timeoutMillis * @return * @throws RemotingConnectException * @throws RemotingSendRequestException * @throws RemotingTimeoutException * @throws InterruptedException * @throws MQBrokerException */ public KVTable getBrokerRuntimeInfo(final String addr, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_RUNTIME_INFO, null); RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { return KVTable.decode(response.getBody(), KVTable.class); } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #25
Source File: MQClientAPIImpl.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
/** * 更新Broker上的配置 * * @param addr * @param properties * @param timeoutMillis * @throws RemotingConnectException * @throws RemotingSendRequestException * @throws RemotingTimeoutException * @throws InterruptedException * @throws MQBrokerException * @throws UnsupportedEncodingException */ public void updateBrokerConfig(final String addr, final Properties properties, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException, UnsupportedEncodingException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_BROKER_CONFIG, null); String str = MixAll.properties2String(properties); if (str != null && str.length() > 0) { request.setBody(str.getBytes(MixAll.DEFAULT_CHARSET)); RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { return; } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); } }
Example #26
Source File: MQClientAPIImpl.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
/** * Broker 查询topic被谁消费 * * @param addr * @param topic * @param timeoutMillis * @return * @throws RemotingConnectException * @throws RemotingSendRequestException * @throws RemotingTimeoutException * @throws InterruptedException * @throws MQBrokerException */ public GroupList queryTopicConsumeByWho(final String addr, final String topic, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { QueryTopicConsumeByWhoRequestHeader requestHeader = new QueryTopicConsumeByWhoRequestHeader(); requestHeader.setTopic(topic); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_TOPIC_CONSUME_BY_WHO, requestHeader); RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { GroupList groupList = GroupList.decode(response.getBody(), GroupList.class); return groupList; } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #27
Source File: MQClientAPIImpl.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
/** * 根据 topic 和 group 获取消息的时间跨度 * * @param addr * @param topic * @param group * @param timeoutMillis * @return * @throws RemotingConnectException * @throws RemotingSendRequestException * @throws RemotingTimeoutException * @throws InterruptedException * @throws MQBrokerException */ public Set<QueueTimeSpan> queryConsumeTimeSpan(final String addr, final String topic, final String group, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { QueryConsumeTimeSpanRequestHeader requestHeader = new QueryConsumeTimeSpanRequestHeader(); requestHeader.setTopic(topic); requestHeader.setGroup(group); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUME_TIME_SPAN, requestHeader); RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { QueryConsumeTimeSpanBody consumeTimeSpanBody = GroupList.decode(response.getBody(), QueryConsumeTimeSpanBody.class); return consumeTimeSpanBody.getConsumeTimeSpanSet(); } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #28
Source File: MQClientAPIImpl.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
/** * 向Filter Server注册Class * * @param addr * @param consumerGroup * @param topic * @param className * @param classCRC * @param classBody * @param timeoutMillis * @throws RemotingConnectException * @throws RemotingSendRequestException * @throws RemotingTimeoutException * @throws InterruptedException * @throws MQBrokerException */ public void registerMessageFilterClass(final String addr, final String consumerGroup, final String topic, final String className, final int classCRC, final byte[] classBody, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { RegisterMessageFilterClassRequestHeader requestHeader = new RegisterMessageFilterClassRequestHeader(); requestHeader.setConsumerGroup(consumerGroup); requestHeader.setClassName(className); requestHeader.setTopic(topic); requestHeader.setClassCRC(classCRC); RemotingCommand request = RemotingCommand .createRequestCommand(RequestCode.REGISTER_MESSAGE_FILTER_CLASS, requestHeader); request.setBody(classBody); RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { return; } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #29
Source File: MQClientAPIImpl.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
/** * 清理失效队列 * * @param addr * @param timeoutMillis * @return * @throws MQClientException * @throws RemotingConnectException * @throws RemotingSendRequestException * @throws RemotingTimeoutException * @throws InterruptedException */ public boolean cleanExpiredConsumeQueue(final String addr, long timeoutMillis) throws MQClientException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CLEAN_EXPIRED_CONSUMEQUEUE, null); RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { return true; } default: break; } throw new MQClientException(response.getCode(), response.getRemark()); }
Example #30
Source File: DefaultRequestProcessor.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
@Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws Exception { if (log.isDebugEnabled()) { log.debug("receive request, {} {} {}", // request.getCode(), // RemotingHelper.parseChannelRemoteAddr(ctx.channel()), // request); } switch (request.getCode()) { case RequestCode.REGISTER_MESSAGE_FILTER_CLASS: return registerMessageFilterClass(ctx, request); case RequestCode.PULL_MESSAGE: return pullMessageForward(ctx, request); } return null; }