org.apache.rocketmq.broker.client.ClientChannelInfo Java Examples
The following examples show how to use
org.apache.rocketmq.broker.client.ClientChannelInfo.
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: ClientManageProcessorTest.java From DDMQ with Apache License 2.0 | 6 votes |
@Before public void init() { when(handlerContext.channel()).thenReturn(channel); clientManageProcessor = new ClientManageProcessor(brokerController); clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100); brokerController.getProducerManager().registerProducer(group, clientChannelInfo); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #2
Source File: ClientManageProcessorTest.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Before public void init() { when(handlerContext.channel()).thenReturn(channel); clientManageProcessor = new ClientManageProcessor(brokerController); clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100); brokerController.getProducerManager().registerProducer(group, clientChannelInfo); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #3
Source File: DeFiPullMessageProcessor.java From DeFiBus with Apache License 2.0 | 6 votes |
@Override public RemotingCommand processRequest(final ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { RemotingCommand response = super.processRequest(ctx, request); final PullMessageRequestHeader requestHeader = (PullMessageRequestHeader) request.decodeCommandCustomHeader(PullMessageRequestHeader.class); ConsumerGroupInfo consumerGroupInfo = deFiBrokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup()); if (consumerGroupInfo != null) { ClientChannelInfo clientChannelInfo = consumerGroupInfo.getChannelInfoTable().get(ctx.channel()); if (clientChannelInfo != null) { String clientId = clientChannelInfo.getClientId(); deFiBrokerController.getClientRebalanceResultManager().updateListenMap(requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId(), clientId); } } handleProcessResult(requestHeader, response); return response; }
Example #4
Source File: DeFiConsumerGroupInfo.java From DeFiBus with Apache License 2.0 | 6 votes |
public Set<String> unregisterClientId(final ClientChannelInfo clientChannelInfo) { Set<String> whichTopic = new HashSet<>(); if (clientChannelInfo != null) { String clientId = clientChannelInfo.getClientId(); Iterator<Map.Entry<String, CopyOnWriteArraySet<String>>> it = clientIdMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, CopyOnWriteArraySet<String>> entry = it.next(); if (entry.getValue().contains(clientId)) { log.info("unregister clientId {} from {}", clientId, entry.getKey()); entry.getValue().remove(clientId); whichTopic.add(entry.getKey()); if (entry.getValue().isEmpty()) { log.info("unregister clientId, clientId set of {} is empty, remove it.", entry.getKey()); it.remove(); } } } } return whichTopic; }
Example #5
Source File: PullMessageProcessorTest.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Before public void init() { brokerController.setMessageStore(messageStore); pullMessageProcessor = new PullMessageProcessor(brokerController); Channel mockChannel = mock(Channel.class); when(mockChannel.remoteAddress()).thenReturn(new InetSocketAddress(1024)); when(handlerContext.channel()).thenReturn(mockChannel); brokerController.getTopicConfigManager().getTopicConfigTable().put(topic, new TopicConfig()); clientChannelInfo = new ClientChannelInfo(mockChannel); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #6
Source File: PullMessageProcessorTest.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Before public void init() { brokerController.setMessageStore(messageStore); pullMessageProcessor = new PullMessageProcessor(brokerController); Channel mockChannel = mock(Channel.class); when(mockChannel.remoteAddress()).thenReturn(new InetSocketAddress(1024)); when(handlerContext.channel()).thenReturn(mockChannel); brokerController.getTopicConfigManager().getTopicConfigTable().put(topic, new TopicConfig()); clientChannelInfo = new ClientChannelInfo(mockChannel); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #7
Source File: ClientManageProcessorTest.java From rocketmq with Apache License 2.0 | 6 votes |
@Before public void init() { when(handlerContext.channel()).thenReturn(channel); clientManageProcessor = new ClientManageProcessor(brokerController); clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100); brokerController.getProducerManager().registerProducer(group, clientChannelInfo); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #8
Source File: PullMessageProcessorTest.java From rocketmq with Apache License 2.0 | 6 votes |
@Before public void init() { brokerController.setMessageStore(messageStore); pullMessageProcessor = new PullMessageProcessor(brokerController); Channel mockChannel = mock(Channel.class); when(mockChannel.remoteAddress()).thenReturn(new InetSocketAddress(1024)); when(handlerContext.channel()).thenReturn(mockChannel); brokerController.getTopicConfigManager().getTopicConfigTable().put(topic, new TopicConfig()); clientChannelInfo = new ClientChannelInfo(mockChannel); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #9
Source File: ClientManageProcessorTest.java From rocketmq with Apache License 2.0 | 6 votes |
@Before public void init() { when(handlerContext.channel()).thenReturn(channel); clientManageProcessor = new ClientManageProcessor(brokerController); clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100); brokerController.getProducerManager().registerProducer(group, clientChannelInfo); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #10
Source File: ClientManageProcessorTest.java From DDMQ with Apache License 2.0 | 6 votes |
@Before public void init() { when(handlerContext.channel()).thenReturn(channel); clientManageProcessor = new ClientManageProcessor(brokerController); clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100); brokerController.getProducerManager().registerProducer(group, clientChannelInfo); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #11
Source File: PullMessageProcessorTest.java From DDMQ with Apache License 2.0 | 6 votes |
@Before public void init() { brokerController.setMessageStore(messageStore); pullMessageProcessor = new PullMessageProcessor(brokerController); Channel mockChannel = mock(Channel.class); when(mockChannel.remoteAddress()).thenReturn(new InetSocketAddress(1024)); when(handlerContext.channel()).thenReturn(mockChannel); brokerController.getTopicConfigManager().getTopicConfigTable().put(topic, new TopicConfig()); clientChannelInfo = new ClientChannelInfo(mockChannel); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #12
Source File: PullMessageProcessorTest.java From rocketmq with Apache License 2.0 | 6 votes |
@Before public void init() { brokerController.setMessageStore(messageStore); pullMessageProcessor = new PullMessageProcessor(brokerController); Channel mockChannel = mock(Channel.class); when(mockChannel.remoteAddress()).thenReturn(new InetSocketAddress(1024)); when(handlerContext.channel()).thenReturn(mockChannel); brokerController.getTopicConfigManager().getTopicConfigTable().put(topic, new TopicConfig()); clientChannelInfo = new ClientChannelInfo(mockChannel); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #13
Source File: ClientManageProcessorTest.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Before public void init() { when(handlerContext.channel()).thenReturn(channel); clientManageProcessor = new ClientManageProcessor(brokerController); clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100); brokerController.getProducerManager().registerProducer(group, clientChannelInfo); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #14
Source File: DeFiConsumerManager.java From DeFiBus with Apache License 2.0 | 6 votes |
@Override public void doChannelCloseEvent(final String remoteAddr, final Channel channel) { Set<String> subscribeTopics = null; Iterator<Map.Entry<String, ConsumerGroupInfo>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, ConsumerGroupInfo> next = it.next(); ConsumerGroupInfo info = next.getValue(); if (info.getChannelInfoTable().get(channel) != null) { ClientChannelInfo clientChannelInfo = info.getChannelInfoTable().get(channel); DeFiConsumerGroupInfo deFiConsumerGroupInfo = (DeFiConsumerGroupInfo) info; subscribeTopics = deFiConsumerGroupInfo.findSubscribedTopicByClientId(clientChannelInfo.getClientId()); } } super.doChannelCloseEvent(remoteAddr, channel); if (subscribeTopics != null) { for (String topic : subscribeTopics) { adjustQueueNumStrategy.decreaseQueueNum(topic); } } }
Example #15
Source File: DeFiConsumerManager.java From DeFiBus with Apache License 2.0 | 6 votes |
@Override public void unregisterConsumer(final String group, final ClientChannelInfo clientChannelInfo, boolean isNotifyConsumerIdsChangedEnable) { ConsumerGroupInfo consumerGroupInfo = this.consumerTable.get(group); Set<String> subscribeTopics = null; if (null != consumerGroupInfo) { DeFiConsumerGroupInfo deFiConsumerGroupInfo = (DeFiConsumerGroupInfo) consumerGroupInfo; subscribeTopics = deFiConsumerGroupInfo.unregisterClientId(clientChannelInfo); } super.unregisterConsumer(group, clientChannelInfo, isNotifyConsumerIdsChangedEnable); if (subscribeTopics != null) { for (String topic : subscribeTopics) { adjustQueueNumStrategy.decreaseQueueNum(topic); } } }
Example #16
Source File: DeFiReplyMessageProcessorTest.java From DeFiBus with Apache License 2.0 | 6 votes |
@Before public void init() { deFiBrokerController = spy(new DeFiBrokerController(new BrokerConfig(), new NettyServerConfig(), new NettyClientConfig(), new MessageStoreConfig(), deFiBusBrokerConfig)); channelHandlerContext = mock(ChannelHandlerContext.class); messageStore = mock(MessageStore.class); DeFiBusBroker2Client broker2Client = mock(DeFiBusBroker2Client.class); when(this.deFiBrokerController.getDeFiBusBroker2Client()).thenReturn(broker2Client); when(broker2Client.pushRRReplyMessageToClient(any(), any(), any())).thenReturn(true); Channel channel = mock(Channel.class); when(channel.isActive()).thenReturn(true); ClientChannelInfo channelInfo = mock(ClientChannelInfo.class); when(channelInfo.getChannel()).thenReturn(channel); DeFiProducerManager mockProducer = mock(DeFiProducerManager.class); when(mockProducer.getClientChannel(anyString())).thenReturn(channelInfo); when(this.deFiBrokerController.getProducerManager()).thenReturn(mockProducer); this.deFiBrokerController.setMessageStore(this.messageStore); when(this.messageStore.now()).thenReturn(System.currentTimeMillis()); AppendMessageResult appendMessageResult = new AppendMessageResult(AppendMessageStatus.PUT_OK, 0, 0, "00000000000000000000000000000000", messageStore.now(), 0L, 0); when(this.messageStore.putMessage(any())).thenReturn(new PutMessageResult(PutMessageStatus.PUT_OK, appendMessageResult)); when(channel.remoteAddress()).thenReturn(new InetSocketAddress(1024)); when(channelHandlerContext.channel()).thenReturn(channel); deFiReplyMessageProcessor = new DeFiReplyMessageProcessor(this.deFiBrokerController); }
Example #17
Source File: DeFiPullMessageProcessorTest.java From DeFiBus with Apache License 2.0 | 6 votes |
@Before public void init() { deFiBrokerController.setMessageStore(messageStore); deFiPullMessageProcessor = new DeFiPullMessageProcessor(deFiBrokerController); Channel mockChannel = mock(Channel.class); when(handlerContext.channel()).thenReturn(mockChannel); deFiBrokerController.getTopicConfigManager().getTopicConfigTable().put(topic, new TopicConfig()); clientChannelInfo = new ClientChannelInfo(mockChannel, clientId, LanguageCode.JAVA, 100); ConsumerData consumerData = createConsumerData(group, topic); deFiBrokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #18
Source File: ConsumeQueueManagerTest.java From DeFiBus with Apache License 2.0 | 6 votes |
@Test public void testGetMinAccumulated() throws Exception { clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100); ConsumerData consumerData = createConsumerData(group, topic); deFiBrokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); deFiBrokerController.getConsumerOffsetManager().commitOffset(clientId, group, topic, queueId, offSet); consumeQueueManager.setBrokerController(deFiBrokerController); when(messageStore.getMaxOffsetInQueue(topic, queueId)).thenReturn(1025L); ConsumeQueueWaterMark mark = consumeQueueManager.getMinAccumulated(topic, queueId); assertThat(mark).isNotNull(); assertThat(mark.getTopic()).isEqualTo(topic); assertThat(mark.getConsumerGroup()).isEqualTo(group); assertThat(mark.getAccumulated()).isEqualTo(1); }
Example #19
Source File: DeFiProducerManagerTest.java From DeFiBus with Apache License 2.0 | 6 votes |
@Test public void unregisterProducer() throws Exception { deFiProducerManager.registerProducer(group, clientInfo); HashMap<Channel, ClientChannelInfo> channelMap = deFiProducerManager.getGroupChannelTable().get(group); assertThat(channelMap).isNotNull(); assertThat(channelMap.get(channel)).isEqualTo(clientInfo); assertThat(deFiProducerManager.getProducerChannelTable().get(clientInfo.getClientId())).isNotNull(); assertThat(deFiProducerManager.getProducerChannelTable().get(clientInfo.getClientId())).isEqualTo(clientInfo); deFiProducerManager.unregisterProducer(group, clientInfo); channelMap = deFiProducerManager.getGroupChannelTable().get(group); assertThat(channelMap).isNull(); assertThat(deFiProducerManager.getProducerChannelTable().get(clientInfo.getClientId())).isNull(); assertThat(deFiProducerManager.getProducerChannelTable().get(clientInfo.getClientId())).isNull(); }
Example #20
Source File: PullMessageProcessorTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
@Before public void init() { brokerController.setMessageStore(messageStore); pullMessageProcessor = new PullMessageProcessor(brokerController); Channel mockChannel = mock(Channel.class); when(mockChannel.remoteAddress()).thenReturn(new InetSocketAddress(1024)); when(handlerContext.channel()).thenReturn(mockChannel); brokerController.getTopicConfigManager().getTopicConfigTable().put(topic, new TopicConfig()); clientChannelInfo = new ClientChannelInfo(mockChannel); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #21
Source File: ClientManageProcessorTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
@Before public void init() { when(handlerContext.channel()).thenReturn(channel); clientManageProcessor = new ClientManageProcessor(brokerController); clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100); brokerController.getProducerManager().registerProducer(group, clientChannelInfo); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #22
Source File: PullMessageProcessorTest.java From DDMQ with Apache License 2.0 | 6 votes |
@Before public void init() { brokerController.setMessageStore(messageStore); pullMessageProcessor = new PullMessageProcessor(brokerController); Channel mockChannel = mock(Channel.class); when(mockChannel.remoteAddress()).thenReturn(new InetSocketAddress(1024)); when(handlerContext.channel()).thenReturn(mockChannel); brokerController.getTopicConfigManager().getTopicConfigTable().put(topic, new TopicConfig()); clientChannelInfo = new ClientChannelInfo(mockChannel); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #23
Source File: DefaultTransactionCheckExecuter.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
@Override public void gotoCheck(int producerGroupHashCode, long tranStateTableOffset, long commitLogOffset, int msgSize) { // 第一步、查询Producer final ClientChannelInfo clientChannelInfo = this.brokerController.getProducerManager().pickProducerChannelRandomly(producerGroupHashCode); if (null == clientChannelInfo) { log.warn("check a producer transaction state, but not find any channel of this group[{}]", producerGroupHashCode); return; } // 第二步、查询消息 SelectMappedBufferResult selectMapedBufferResult = this.brokerController.getMessageStore().selectOneMessageByOffset(commitLogOffset, msgSize); if (null == selectMapedBufferResult) { log.warn("check a producer transaction state, but not find message by commitLogOffset: {}, msgSize: ", commitLogOffset, msgSize); return; } // 第三步、向Producer发起请求 final CheckTransactionStateRequestHeader requestHeader = new CheckTransactionStateRequestHeader(); requestHeader.setCommitLogOffset(commitLogOffset); requestHeader.setTranStateTableOffset(tranStateTableOffset); this.brokerController.getBroker2Client().checkProducerTransactionState(clientChannelInfo.getChannel(), requestHeader, selectMapedBufferResult); }
Example #24
Source File: PullMessageProcessorTest.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
@Before public void init() { brokerController.setMessageStore(messageStore); pullMessageProcessor = new PullMessageProcessor(brokerController); Channel mockChannel = mock(Channel.class); when(mockChannel.remoteAddress()).thenReturn(new InetSocketAddress(1024)); when(handlerContext.channel()).thenReturn(mockChannel); brokerController.getTopicConfigManager().getTopicConfigTable().put(topic, new TopicConfig()); clientChannelInfo = new ClientChannelInfo(mockChannel); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #25
Source File: ClientManageProcessorTest.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
@Before public void init() { when(handlerContext.channel()).thenReturn(channel); clientManageProcessor = new ClientManageProcessor(brokerController); clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100); brokerController.getProducerManager().registerProducer(group, clientChannelInfo); ConsumerData consumerData = createConsumerData(group, topic); brokerController.getConsumerManager().registerConsumer( consumerData.getGroupName(), clientChannelInfo, consumerData.getConsumeType(), consumerData.getMessageModel(), consumerData.getConsumeFromWhere(), consumerData.getSubscriptionDataSet(), false); }
Example #26
Source File: DeFiConsumerManager.java From DeFiBus with Apache License 2.0 | 6 votes |
@Override public boolean registerConsumer(final String group, final ClientChannelInfo clientChannelInfo, ConsumeType consumeType, MessageModel messageModel, ConsumeFromWhere consumeFromWhere, final Set<SubscriptionData> subList, boolean isNotifyConsumerIdsChangedEnable) { ConsumerGroupInfo consumerGroupInfo = this.consumerTable.get(group); if (null == consumerGroupInfo) { ConsumerGroupInfo tmp = new DeFiConsumerGroupInfo(group, consumeType, messageModel, consumeFromWhere); ConsumerGroupInfo prev = this.consumerTable.putIfAbsent(group, tmp); consumerGroupInfo = prev != null ? prev : tmp; } DeFiConsumerGroupInfo deFiConsumerGroupInfo = (DeFiConsumerGroupInfo) consumerGroupInfo; Set<String> oldSub = deFiConsumerGroupInfo.findSubscribedTopicByClientId(clientChannelInfo.getClientId()); boolean r1 = super.registerConsumer(group, clientChannelInfo, consumeType, messageModel, consumeFromWhere, subList, isNotifyConsumerIdsChangedEnable); boolean r2 = deFiConsumerGroupInfo.registerClientId(subList, clientChannelInfo.getClientId()); if (r1 || r2) { adjustQueueNum(oldSub, subList); if (isNotifyConsumerIdsChangedEnable) { this.consumerIdsChangeListener.handle(ConsumerGroupEvent.CHANGE, group, consumerGroupInfo.getAllChannel()); } } this.consumerIdsChangeListener.handle(ConsumerGroupEvent.REGISTER, group, subList); return r1 || r2; }
Example #27
Source File: AdminBrokerProcessor.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
private RemotingCommand getConsumerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { final RemotingCommand response = RemotingCommand.createResponseCommand(null); final GetConsumerConnectionListRequestHeader requestHeader = (GetConsumerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetConsumerConnectionListRequestHeader.class); ConsumerGroupInfo consumerGroupInfo = this.brokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup()); if (consumerGroupInfo != null) { ConsumerConnection bodydata = new ConsumerConnection(); bodydata.setConsumeFromWhere(consumerGroupInfo.getConsumeFromWhere()); bodydata.setConsumeType(consumerGroupInfo.getConsumeType()); bodydata.setMessageModel(consumerGroupInfo.getMessageModel()); bodydata.getSubscriptionTable().putAll(consumerGroupInfo.getSubscriptionTable()); Iterator<Map.Entry<Channel, ClientChannelInfo>> it = consumerGroupInfo.getChannelInfoTable().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.CONSUMER_NOT_ONLINE); response.setRemark("the consumer group[" + requestHeader.getConsumerGroup() + "] not online"); return response; }
Example #28
Source File: AdminBrokerProcessor.java From DDMQ with Apache License 2.0 | 5 votes |
private RemotingCommand getConsumerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { final RemotingCommand response = RemotingCommand.createResponseCommand(null); final GetConsumerConnectionListRequestHeader requestHeader = (GetConsumerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetConsumerConnectionListRequestHeader.class); ConsumerGroupInfo consumerGroupInfo = this.brokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup()); if (consumerGroupInfo != null) { ConsumerConnection bodydata = new ConsumerConnection(); bodydata.setConsumeFromWhere(consumerGroupInfo.getConsumeFromWhere()); bodydata.setConsumeType(consumerGroupInfo.getConsumeType()); bodydata.setMessageModel(consumerGroupInfo.getMessageModel()); bodydata.getSubscriptionTable().putAll(consumerGroupInfo.getSubscriptionTable()); Iterator<Map.Entry<Channel, ClientChannelInfo>> it = consumerGroupInfo.getChannelInfoTable().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.CONSUMER_NOT_ONLINE); response.setRemark("the consumer group[" + requestHeader.getConsumerGroup() + "] not online"); return response; }
Example #29
Source File: AdminBrokerProcessor.java From DDMQ with Apache License 2.0 | 5 votes |
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; }
Example #30
Source File: ClientManageProcessorTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void processRequest_UnRegisterProducer() throws Exception { brokerController.getProducerManager().registerProducer(group, clientChannelInfo); HashMap<Channel, ClientChannelInfo> channelMap = brokerController.getProducerManager().getGroupChannelTable().get(group); assertThat(channelMap).isNotNull(); assertThat(channelMap.get(channel)).isEqualTo(clientChannelInfo); RemotingCommand request = createUnRegisterProducerCommand(); RemotingCommand response = clientManageProcessor.processRequest(handlerContext, request); assertThat(response).isNotNull(); assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS); channelMap = brokerController.getProducerManager().getGroupChannelTable().get(group); assertThat(channelMap).isNull(); }