org.apache.rocketmq.client.impl.consumer.MQConsumerInner Java Examples
The following examples show how to use
org.apache.rocketmq.client.impl.consumer.MQConsumerInner.
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: DeFiBusPullMessageService.java From DeFiBus with Apache License 2.0 | 6 votes |
private void pullMessage(final PullRequest pullRequest) { final MQConsumerInner consumer = this.mQClientFactory.selectConsumer(pullRequest.getConsumerGroup()); if (consumer != null) { long beginPullRequestTime = System.currentTimeMillis(); DefaultMQPushConsumerImpl impl = (DefaultMQPushConsumerImpl) consumer; log.debug("begin Pull Message, {}", pullRequest); impl.pullMessage(pullRequest); long rt = System.currentTimeMillis() - beginPullRequestTime; if (rt >= brokerHealthyManager.getIsolateThreshold()) { brokerHealthyManager.isolateBroker(pullRequest.getMessageQueue().getBrokerName()); } } else { log.warn("No matched consumer for the PullRequest {}, drop it", pullRequest); } }
Example #2
Source File: MQClientInstance.java From DDMQ with Apache License 2.0 | 6 votes |
public void adjustThreadPool() { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> entry = it.next(); MQConsumerInner impl = entry.getValue(); if (impl != null) { try { if (impl instanceof DefaultMQPushConsumerImpl) { DefaultMQPushConsumerImpl dmq = (DefaultMQPushConsumerImpl) impl; dmq.adjustThreadPool(); } } catch (Exception e) { } } } }
Example #3
Source File: MQClientInstance.java From DDMQ with Apache License 2.0 | 6 votes |
private void uploadFilterClassSource() { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> next = it.next(); MQConsumerInner consumer = next.getValue(); if (ConsumeType.CONSUME_PASSIVELY == consumer.consumeType()) { Set<SubscriptionData> subscriptions = consumer.subscriptions(); for (SubscriptionData sub : subscriptions) { if (sub.isClassFilterMode() && sub.getFilterClassSource() != null) { final String consumerGroup = consumer.groupName(); final String className = sub.getSubString(); final String topic = sub.getTopic(); final String filterClassSource = sub.getFilterClassSource(); try { this.uploadFilterClassToAllFilterServer(consumerGroup, className, topic, filterClassSource); } catch (Exception e) { log.error("uploadFilterClassToAllFilterServer Exception", e); } } } } } }
Example #4
Source File: MQClientInstance.java From DDMQ with Apache License 2.0 | 6 votes |
public void adjustThreadPool() { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> entry = it.next(); MQConsumerInner impl = entry.getValue(); if (impl != null) { try { if (impl instanceof DefaultMQPushConsumerImpl) { DefaultMQPushConsumerImpl dmq = (DefaultMQPushConsumerImpl) impl; dmq.adjustThreadPool(); } } catch (Exception e) { } } } }
Example #5
Source File: MQClientInstance.java From DDMQ with Apache License 2.0 | 6 votes |
private void uploadFilterClassSource() { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> next = it.next(); MQConsumerInner consumer = next.getValue(); if (ConsumeType.CONSUME_PASSIVELY == consumer.consumeType()) { Set<SubscriptionData> subscriptions = consumer.subscriptions(); for (SubscriptionData sub : subscriptions) { if (sub.isClassFilterMode() && sub.getFilterClassSource() != null) { final String consumerGroup = consumer.groupName(); final String className = sub.getSubString(); final String topic = sub.getTopic(); final String filterClassSource = sub.getFilterClassSource(); try { this.uploadFilterClassToAllFilterServer(consumerGroup, className, topic, filterClassSource); } catch (Exception e) { log.error("uploadFilterClassToAllFilterServer Exception", e); } } } } } }
Example #6
Source File: MQClientInstance.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
private void uploadFilterClassSource() { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> next = it.next(); MQConsumerInner consumer = next.getValue(); if (ConsumeType.CONSUME_PASSIVELY == consumer.consumeType()) { Set<SubscriptionData> subscriptions = consumer.subscriptions(); for (SubscriptionData sub : subscriptions) { if (sub.isClassFilterMode() && sub.getFilterClassSource() != null) { final String consumerGroup = consumer.groupName(); final String className = sub.getSubString(); final String topic = sub.getTopic(); final String filterClassSource = sub.getFilterClassSource(); try { this.uploadFilterClassToAllFilterServer(consumerGroup, className, topic, filterClassSource); } catch (Exception e) { log.error("uploadFilterClassToAllFilterServer Exception", e); } } } } } }
Example #7
Source File: MQClientInstance.java From rocketmq with Apache License 2.0 | 6 votes |
private void uploadFilterClassSource() { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> next = it.next(); MQConsumerInner consumer = next.getValue(); if (ConsumeType.CONSUME_PASSIVELY == consumer.consumeType()) { Set<SubscriptionData> subscriptions = consumer.subscriptions(); for (SubscriptionData sub : subscriptions) { if (sub.isClassFilterMode() && sub.getFilterClassSource() != null) { final String consumerGroup = consumer.groupName(); final String className = sub.getSubString(); final String topic = sub.getTopic(); final String filterClassSource = sub.getFilterClassSource(); try { this.uploadFilterClassToAllFilterServer(consumerGroup, className, topic, filterClassSource); } catch (Exception e) { log.error("uploadFilterClassToAllFilterServer Exception", e); } } } } } }
Example #8
Source File: MQClientInstance.java From rocketmq with Apache License 2.0 | 6 votes |
public void adjustThreadPool() { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> entry = it.next(); MQConsumerInner impl = entry.getValue(); if (impl != null) { try { if (impl instanceof DefaultMQPushConsumerImpl) { DefaultMQPushConsumerImpl dmq = (DefaultMQPushConsumerImpl) impl; dmq.adjustThreadPool(); } } catch (Exception e) { } } } }
Example #9
Source File: MQClientInstance.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
public void adjustThreadPool() { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> entry = it.next(); MQConsumerInner impl = entry.getValue(); if (impl != null) { try { if (impl instanceof DefaultMQPushConsumerImpl) { DefaultMQPushConsumerImpl dmq = (DefaultMQPushConsumerImpl) impl; dmq.adjustThreadPool(); } } catch (Exception e) { } } } }
Example #10
Source File: MQClientInstance.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
public void adjustThreadPool() { // 遍历消费者 Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> entry = it.next(); MQConsumerInner impl = entry.getValue(); if (impl != null) { try { if (impl instanceof DefaultMQPushConsumerImpl) { DefaultMQPushConsumerImpl dmq = (DefaultMQPushConsumerImpl) impl; // =》 dmq.adjustThreadPool(); } } catch (Exception e) { } } } }
Example #11
Source File: MQClientInstance.java From rocketmq-read with Apache License 2.0 | 6 votes |
public void adjustThreadPool() { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> entry = it.next(); MQConsumerInner impl = entry.getValue(); if (impl != null) { try { if (impl instanceof DefaultMQPushConsumerImpl) { DefaultMQPushConsumerImpl dmq = (DefaultMQPushConsumerImpl) impl; dmq.adjustThreadPool(); } } catch (Exception e) { } } } }
Example #12
Source File: MQClientInstance.java From DDMQ with Apache License 2.0 | 5 votes |
public void doRebalance() { for (Map.Entry<String, MQConsumerInner> entry : this.consumerTable.entrySet()) { MQConsumerInner impl = entry.getValue(); if (impl != null) { try { impl.doRebalance(); } catch (Throwable e) { log.error("doRebalance exception", e); } } } }
Example #13
Source File: MQClientInstance.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
private void persistAllConsumerOffset() { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> entry = it.next(); MQConsumerInner impl = entry.getValue(); impl.persistConsumerOffset(); } }
Example #14
Source File: MQClientInstance.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
public void checkClientInBroker() throws MQClientException { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> entry = it.next(); Set<SubscriptionData> subscriptionInner = entry.getValue().subscriptions(); if (subscriptionInner == null || subscriptionInner.isEmpty()) { return; } for (SubscriptionData subscriptionData : subscriptionInner) { if (ExpressionType.isTagType(subscriptionData.getExpressionType())) { continue; } // may need to check one broker every cluster... // assume that the configs of every broker in cluster are the the same. String addr = findBrokerAddrByTopic(subscriptionData.getTopic()); if (addr != null) { try { this.getMQClientAPIImpl().checkClientInBroker( addr, entry.getKey(), this.clientId, subscriptionData, 3 * 1000 ); } catch (Exception e) { if (e instanceof MQClientException) { throw (MQClientException) e; } else { throw new MQClientException("Check client in broker error, maybe because you use " + subscriptionData.getExpressionType() + " to filter message, but server has not been upgraded to support!" + "This error would not affect the launch of consumer, but may has impact on message receiving if you " + "have use the new features which are not supported by server, please check the log!", e); } } } } } }
Example #15
Source File: MQClientInstanceTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Test public void testRegisterConsumer() throws RemotingException, InterruptedException, MQBrokerException { boolean flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isTrue(); flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isFalse(); mqClientInstance.unregisterConsumer(group); flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isTrue(); }
Example #16
Source File: MQClientInstance.java From DDMQ with Apache License 2.0 | 5 votes |
public ConsumeMessageDirectlyResult consumeMessageDirectly(final MessageExt msg, final String consumerGroup, final String brokerName) { MQConsumerInner mqConsumerInner = this.consumerTable.get(consumerGroup); if (null != mqConsumerInner) { DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) mqConsumerInner; ConsumeMessageDirectlyResult result = consumer.getConsumeMessageService().consumeMessageDirectly(msg, brokerName); return result; } return null; }
Example #17
Source File: MQClientInstance.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
public void doRebalance() { for (Map.Entry<String, MQConsumerInner> entry : this.consumerTable.entrySet()) { MQConsumerInner impl = entry.getValue(); if (impl != null) { try { impl.doRebalance(); } catch (Throwable e) { log.error("doRebalance exception", e); } } } }
Example #18
Source File: MQClientInstance.java From DDMQ with Apache License 2.0 | 5 votes |
public boolean registerConsumer(final String group, final MQConsumerInner consumer) { if (null == group || null == consumer) { return false; } MQConsumerInner prev = this.consumerTable.putIfAbsent(group, consumer); if (prev != null) { log.warn("the consumer group[" + group + "] exist already."); return false; } return true; }
Example #19
Source File: MQClientInstance.java From DDMQ with Apache License 2.0 | 5 votes |
private void persistAllConsumerOffset() { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> entry = it.next(); MQConsumerInner impl = entry.getValue(); impl.persistConsumerOffset(); } }
Example #20
Source File: MQClientInstance.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
public boolean registerConsumer(final String group, final MQConsumerInner consumer) { if (null == group || null == consumer) { return false; } MQConsumerInner prev = this.consumerTable.putIfAbsent(group, consumer); if (prev != null) { log.warn("the consumer group[" + group + "] exist already."); return false; } return true; }
Example #21
Source File: MQClientInstanceTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testRegisterConsumer() throws RemotingException, InterruptedException, MQBrokerException { boolean flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isTrue(); flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isFalse(); mqClientInstance.unregisterConsumer(group); flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isTrue(); }
Example #22
Source File: MQClientInstance.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
public ConsumeMessageDirectlyResult consumeMessageDirectly(final MessageExt msg, // final String consumerGroup, // final String brokerName) { MQConsumerInner mqConsumerInner = this.consumerTable.get(consumerGroup); if (null != mqConsumerInner) { DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) mqConsumerInner; ConsumeMessageDirectlyResult result = consumer.getConsumeMessageService().consumeMessageDirectly(msg, brokerName); return result; } return null; }
Example #23
Source File: MQClientInstanceTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@Test public void testRegisterConsumer() throws RemotingException, InterruptedException, MQBrokerException { boolean flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isTrue(); flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isFalse(); mqClientInstance.unregisterConsumer(group); flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isTrue(); }
Example #24
Source File: MQClientInstanceTest.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
@Test public void testRegisterConsumer() throws RemotingException, InterruptedException, MQBrokerException { boolean flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isTrue(); flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isFalse(); mqClientInstance.unregisterConsumer(group); flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isTrue(); }
Example #25
Source File: MQClientInstance.java From rocketmq with Apache License 2.0 | 5 votes |
public void checkClientInBroker() throws MQClientException { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> entry = it.next(); Set<SubscriptionData> subscriptionInner = entry.getValue().subscriptions(); if (subscriptionInner == null || subscriptionInner.isEmpty()) { return; } for (SubscriptionData subscriptionData : subscriptionInner) { if (ExpressionType.isTagType(subscriptionData.getExpressionType())) { continue; } // may need to check one broker every cluster... // assume that the configs of every broker in cluster are the the same. String addr = findBrokerAddrByTopic(subscriptionData.getTopic()); if (addr != null) { try { this.getMQClientAPIImpl().checkClientInBroker( addr, entry.getKey(), this.clientId, subscriptionData, 3 * 1000 ); } catch (Exception e) { if (e instanceof MQClientException) { throw (MQClientException) e; } else { throw new MQClientException("Check client in broker error, maybe because you use " + subscriptionData.getExpressionType() + " to filter message, but server has not been upgraded to support!" + "This error would not affect the launch of consumer, but may has impact on message receiving if you " + "have use the new features which are not supported by server, please check the log!", e); } } } } } }
Example #26
Source File: MQClientInstance.java From rocketmq with Apache License 2.0 | 5 votes |
private void persistAllConsumerOffset() { Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, MQConsumerInner> entry = it.next(); MQConsumerInner impl = entry.getValue(); impl.persistConsumerOffset(); } }
Example #27
Source File: MQClientInstance.java From rocketmq with Apache License 2.0 | 5 votes |
public boolean registerConsumer(final String group, final MQConsumerInner consumer) { if (null == group || null == consumer) { return false; } MQConsumerInner prev = this.consumerTable.putIfAbsent(group, consumer); if (prev != null) { log.warn("the consumer group[" + group + "] exist already."); return false; } return true; }
Example #28
Source File: MQClientInstance.java From rocketmq with Apache License 2.0 | 5 votes |
public void doRebalance() { for (Map.Entry<String, MQConsumerInner> entry : this.consumerTable.entrySet()) { MQConsumerInner impl = entry.getValue(); if (impl != null) { try { impl.doRebalance(); } catch (Throwable e) { log.error("doRebalance exception", e); } } } }
Example #29
Source File: MQClientInstance.java From rocketmq with Apache License 2.0 | 5 votes |
public ConsumeMessageDirectlyResult consumeMessageDirectly(final MessageExt msg, final String consumerGroup, final String brokerName) { MQConsumerInner mqConsumerInner = this.consumerTable.get(consumerGroup); if (null != mqConsumerInner) { DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) mqConsumerInner; ConsumeMessageDirectlyResult result = consumer.getConsumeMessageService().consumeMessageDirectly(msg, brokerName); return result; } return null; }
Example #30
Source File: MQClientInstanceTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testRegisterConsumer() throws RemotingException, InterruptedException, MQBrokerException { boolean flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isTrue(); flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isFalse(); mqClientInstance.unregisterConsumer(group); flag = mqClientInstance.registerConsumer(group, mock(MQConsumerInner.class)); assertThat(flag).isTrue(); }