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;
}
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();
}
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();
}
}
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;
}
Aggregations