Search in sources :

Example 31 with SubscriptionGroupConfig

use of org.apache.rocketmq.common.subscription.SubscriptionGroupConfig in project rocketmq by apache.

the class SubscriptionGroupManager method findSubscriptionGroupConfig.

public SubscriptionGroupConfig findSubscriptionGroupConfig(final String group) {
    SubscriptionGroupConfig subscriptionGroupConfig = this.subscriptionGroupTable.get(group);
    if (null == subscriptionGroupConfig) {
        if (brokerController.getBrokerConfig().isAutoCreateSubscriptionGroup() || MixAll.isSysConsumerGroup(group)) {
            subscriptionGroupConfig = new SubscriptionGroupConfig();
            subscriptionGroupConfig.setGroupName(group);
            SubscriptionGroupConfig preConfig = this.subscriptionGroupTable.putIfAbsent(group, subscriptionGroupConfig);
            if (null == preConfig) {
                log.info("auto create a subscription group, {}", subscriptionGroupConfig.toString());
            }
            this.dataVersion.nextVersion();
            this.persist();
        }
    }
    return subscriptionGroupConfig;
}
Also used : SubscriptionGroupConfig(org.apache.rocketmq.common.subscription.SubscriptionGroupConfig)

Example 32 with SubscriptionGroupConfig

use of org.apache.rocketmq.common.subscription.SubscriptionGroupConfig in project rocketmq by apache.

the class SubscriptionGroupManager method updateSubscriptionGroupConfig.

public void updateSubscriptionGroupConfig(final SubscriptionGroupConfig config) {
    SubscriptionGroupConfig old = this.subscriptionGroupTable.put(config.getGroupName(), config);
    if (old != null) {
        log.info("update subscription group config, old: {} new: {}", old, config);
    } else {
        log.info("create new subscription group, {}", config);
    }
    this.dataVersion.nextVersion();
    this.persist();
}
Also used : SubscriptionGroupConfig(org.apache.rocketmq.common.subscription.SubscriptionGroupConfig)

Example 33 with SubscriptionGroupConfig

use of org.apache.rocketmq.common.subscription.SubscriptionGroupConfig in project rocketmq by apache.

the class SubscriptionGroupManager method disableConsume.

public void disableConsume(final String groupName) {
    SubscriptionGroupConfig old = this.subscriptionGroupTable.get(groupName);
    if (old != null) {
        old.setConsumeEnable(false);
        this.dataVersion.nextVersion();
    }
}
Also used : SubscriptionGroupConfig(org.apache.rocketmq.common.subscription.SubscriptionGroupConfig)

Example 34 with SubscriptionGroupConfig

use of org.apache.rocketmq.common.subscription.SubscriptionGroupConfig in project rocketmq by apache.

the class MQAdmin method createSub.

public static boolean createSub(String nameSrvAddr, String clusterName, String consumerId) {
    boolean createResult = true;
    DefaultMQAdminExt mqAdminExt = new DefaultMQAdminExt();
    mqAdminExt.setNamesrvAddr(nameSrvAddr);
    SubscriptionGroupConfig config = new SubscriptionGroupConfig();
    config.setGroupName(consumerId);
    try {
        mqAdminExt.start();
        Set<String> masterSet = CommandUtil.fetchMasterAddrByClusterName(mqAdminExt, clusterName);
        for (String addr : masterSet) {
            try {
                mqAdminExt.createAndUpdateSubscriptionGroupConfig(addr, config);
                log.info(String.format("create subscription group %s to %s success.\n", consumerId, addr));
            } catch (Exception e) {
                e.printStackTrace();
                Thread.sleep(1000 * 1);
            }
        }
    } catch (Exception e) {
        createResult = false;
        e.printStackTrace();
    }
    mqAdminExt.shutdown();
    return createResult;
}
Also used : DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt) SubscriptionGroupConfig(org.apache.rocketmq.common.subscription.SubscriptionGroupConfig)

Aggregations

SubscriptionGroupConfig (org.apache.rocketmq.common.subscription.SubscriptionGroupConfig)34 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)12 DefaultMQAdminExt (org.apache.rocketmq.tools.admin.DefaultMQAdminExt)7 TopicConfig (org.apache.rocketmq.common.TopicConfig)6 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)6 SubscriptionData (org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData)6 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 HashMap (java.util.HashMap)4 List (java.util.List)4 Set (java.util.Set)4 ClientChannelInfo (org.apache.rocketmq.broker.client.ClientChannelInfo)4 ConsumeMessageContext (org.apache.rocketmq.broker.mqtrace.ConsumeMessageContext)4 ConsumeStats (org.apache.rocketmq.common.admin.ConsumeStats)4 OffsetWrapper (org.apache.rocketmq.common.admin.OffsetWrapper)4 MQClientException (org.apache.rocketmq.client.exception.MQClientException)3 MessageExt (org.apache.rocketmq.common.message.MessageExt)3 ConsumeStatsList (org.apache.rocketmq.common.protocol.body.ConsumeStatsList)3 GroupList (org.apache.rocketmq.common.protocol.body.GroupList)3 TopicList (org.apache.rocketmq.common.protocol.body.TopicList)3