Java Code Examples for com.alibaba.rocketmq.common.filter.FilterAPI#buildSubscriptionData()
The following examples show how to use
com.alibaba.rocketmq.common.filter.FilterAPI#buildSubscriptionData() .
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: DefaultMQPushConsumerImpl.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 6 votes |
public void subscribe(String topic, String fullClassName, String filterClassSource) throws MQClientException { try { SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(),// topic, "*"); subscriptionData.setSubString(fullClassName); subscriptionData.setClassFilterMode(true); subscriptionData.setFilterClassSource(filterClassSource); this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData); if (this.mQClientFactory != null) { this.mQClientFactory.sendHeartbeatToAllBrokerWithLock(); } } catch (Exception e) { throw new MQClientException("subscription exception", e); } }
Example 2
Source File: DefaultMQPullConsumerImpl.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
private void copySubscription() throws MQClientException { try { Set<String> registerTopics = this.defaultMQPullConsumer.getRegisterTopics(); if (registerTopics != null) { for (final String topic : registerTopics) { SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), // topic, SubscriptionData.SUB_ALL); this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData); } } } catch (Exception e) { throw new MQClientException("subscription exception", e); } }
Example 3
Source File: DefaultMQPullConsumerImpl.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
@Override public Set<SubscriptionData> subscriptions() { Set<SubscriptionData> result = new HashSet<SubscriptionData>(); Set<String> topics = this.defaultMQPullConsumer.getRegisterTopics(); if (topics != null) { synchronized (topics) { for (String t : topics) { SubscriptionData ms = null; try { ms = FilterAPI.buildSubscriptionData(this.groupName(), t, SubscriptionData.SUB_ALL); } catch (Exception e) { log.error("parse subscription error", e); } ms.setSubVersion(0L); result.add(ms); } } } return result; }
Example 4
Source File: DefaultMQPushConsumerImpl.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
public void subscribe(String topic, String fullClassName, String filterClassSource) throws MQClientException { try { SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), // topic, "*"); subscriptionData.setSubString(fullClassName); subscriptionData.setClassFilterMode(true); subscriptionData.setFilterClassSource(filterClassSource); this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData); if (this.mQClientFactory != null) { this.mQClientFactory.sendHeartbeatToAllBrokerWithLock(); } } catch (Exception e) { throw new MQClientException("subscription exception", e); } }
Example 5
Source File: DefaultMQPullConsumerImpl.java From rocketmq with Apache License 2.0 | 6 votes |
@Override public Set<SubscriptionData> subscriptions() { Set<SubscriptionData> result = new HashSet<SubscriptionData>(); Set<String> topics = this.defaultMQPullConsumer.getRegisterTopics(); if (topics != null) { synchronized (topics) { for (String t : topics) { SubscriptionData ms = null; try { ms = FilterAPI.buildSubscriptionData(this.groupName(), t, SubscriptionData.SUB_ALL); } catch (Exception e) { log.error("parse subscription error", e); return null; } ms.setSubVersion(0L); result.add(ms); } } } return result; }
Example 6
Source File: DefaultMQPushConsumerImpl.java From rocketmq with Apache License 2.0 | 6 votes |
public void subscribe(String topic, String fullClassName, String filterClassSource) throws MQClientException { try { SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), // topic, "*"); subscriptionData.setSubString(fullClassName); subscriptionData.setClassFilterMode(true); subscriptionData.setFilterClassSource(filterClassSource); this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData); if (this.mQClientFactory != null) { this.mQClientFactory.sendHeartbeatToAllBrokerWithLock(); } } catch (Exception e) { throw new MQClientException("subscription exception", e); } }
Example 7
Source File: DefaultMQPullConsumerImpl.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 6 votes |
@Override public Set<SubscriptionData> subscriptions() { Set<SubscriptionData> result = new HashSet<SubscriptionData>(); Set<String> topics = this.defaultMQPullConsumer.getRegisterTopics(); if (topics != null) { synchronized (topics) { for (String t : topics) { SubscriptionData ms = null; try { ms = FilterAPI.buildSubscriptionData(this.groupName(), t, SubscriptionData.SUB_ALL); } catch (Exception e) { log.error("parse subscription error", e); } ms.setSubVersion(0L); result.add(ms); } } } return result; }
Example 8
Source File: DefaultMQPushConsumerImpl.java From rocketmq with Apache License 2.0 | 5 votes |
public void subscribe(String topic, String subExpression) throws MQClientException { try { SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), // topic, subExpression); this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData); if (this.mQClientFactory != null) { this.mQClientFactory.sendHeartbeatToAllBrokerWithLock(); } } catch (Exception e) { throw new MQClientException("subscription exception", e); } }
Example 9
Source File: DefaultMQPullConsumerImpl.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
private void copySubscription() throws MQClientException { try { Set<String> registerTopics = this.defaultMQPullConsumer.getRegisterTopics(); if (registerTopics != null) { for (final String topic : registerTopics) { SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(),// topic, SubscriptionData.SUB_ALL); this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData); } } } catch (Exception e) { throw new MQClientException("subscription exception", e); } }
Example 10
Source File: DefaultMQPullConsumerImpl.java From rocketmq with Apache License 2.0 | 5 votes |
private void subscriptionAutomatically(final String topic) { if (!this.rebalanceImpl.getSubscriptionInner().containsKey(topic)) { try { SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), // topic, SubscriptionData.SUB_ALL); this.rebalanceImpl.subscriptionInner.putIfAbsent(topic, subscriptionData); } catch (Exception e) { } } }
Example 11
Source File: DefaultMQPullConsumerImpl.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
private void subscriptionAutomatically(final String topic) { if (!this.rebalanceImpl.getSubscriptionInner().containsKey(topic)) { try { SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(),// topic, SubscriptionData.SUB_ALL); this.rebalanceImpl.subscriptionInner.putIfAbsent(topic, subscriptionData); } catch (Exception e) { } } }
Example 12
Source File: DefaultMQPullConsumerImpl.java From rocketmq with Apache License 2.0 | 5 votes |
private void copySubscription() throws MQClientException { try { Set<String> registerTopics = this.defaultMQPullConsumer.getRegisterTopics(); if (registerTopics != null) { for (final String topic : registerTopics) { SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), // topic, SubscriptionData.SUB_ALL); this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData); } } } catch (Exception e) { throw new MQClientException("subscription exception", e); } }
Example 13
Source File: DefaultMQPushConsumerImpl.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
public void subscribe(String topic, String subExpression) throws MQClientException { try { SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), // topic, subExpression); this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData); if (this.mQClientFactory != null) { this.mQClientFactory.sendHeartbeatToAllBrokerWithLock(); } } catch (Exception e) { throw new MQClientException("subscription exception", e); } }
Example 14
Source File: DefaultMQPullConsumerImpl.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
private void subscriptionAutomatically(final String topic) { if (!this.rebalanceImpl.getSubscriptionInner().containsKey(topic)) { try { SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), // topic, SubscriptionData.SUB_ALL); this.rebalanceImpl.subscriptionInner.putIfAbsent(topic, subscriptionData); } catch (Exception e) { } } }
Example 15
Source File: DefaultMQPushConsumerImpl.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
public void subscribe(String topic, String subExpression) throws MQClientException { try { SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(),// topic, subExpression); this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData); if (this.mQClientFactory != null) { this.mQClientFactory.sendHeartbeatToAllBrokerWithLock(); } } catch (Exception e) { throw new MQClientException("subscription exception", e); } }
Example 16
Source File: DefaultMQPullConsumerImpl.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 4 votes |
private PullResult pullSyncImpl(MessageQueue mq, String subExpression, long offset, int maxNums, boolean block, long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException { this.makeSureStateOK(); if (null == mq) { throw new MQClientException("mq is null", null); } if (offset < 0) { throw new MQClientException("offset < 0", null); } if (maxNums <= 0) { throw new MQClientException("maxNums <= 0", null); } this.subscriptionAutomatically(mq.getTopic()); int sysFlag = PullSysFlag.buildSysFlag(false, block, true, false); SubscriptionData subscriptionData; try { subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(),// mq.getTopic(), subExpression); } catch (Exception e) { throw new MQClientException("parse subscription error", e); } long timeoutMillis = block ? this.defaultMQPullConsumer.getConsumerTimeoutMillisWhenSuspend() : timeout; PullResult pullResult = this.pullAPIWrapper.pullKernelImpl(// mq, // 1 subscriptionData.getSubString(), // 2 0L, // 3 offset, // 4 maxNums, // 5 sysFlag, // 6 0, // 7 this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis(), // 8 timeoutMillis, // 9 CommunicationMode.SYNC, // 10 null// 11 ); return this.pullAPIWrapper.processPullResult(mq, pullResult, subscriptionData); }
Example 17
Source File: DefaultMQPullConsumerImpl.java From RocketMQ-Master-analyze with Apache License 2.0 | 4 votes |
private PullResult pullSyncImpl(MessageQueue mq, String subExpression, long offset, int maxNums, boolean block, long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException { this.makeSureStateOK(); if (null == mq) { throw new MQClientException("mq is null", null); } if (offset < 0) { throw new MQClientException("offset < 0", null); } if (maxNums <= 0) { throw new MQClientException("maxNums <= 0", null); } this.subscriptionAutomatically(mq.getTopic()); int sysFlag = PullSysFlag.buildSysFlag(false, block, true, false); SubscriptionData subscriptionData; try { subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), // mq.getTopic(), subExpression); } catch (Exception e) { throw new MQClientException("parse subscription error", e); } long timeoutMillis = block ? this.defaultMQPullConsumer.getConsumerTimeoutMillisWhenSuspend() : timeout; PullResult pullResult = this.pullAPIWrapper.pullKernelImpl(// mq, // 1 subscriptionData.getSubString(), // 2 0L, // 3 offset, // 4 maxNums, // 5 sysFlag, // 6 0, // 7 this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis(), // 8 timeoutMillis, // 9 CommunicationMode.SYNC, // 10 null// 11 ); return this.pullAPIWrapper.processPullResult(mq, pullResult, subscriptionData); }