use of org.apache.rocketmq.common.subscription.SubscriptionGroupConfig in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class SubscriptionGroupManager method disableConsume.
/**
* 不能消费,设置消费标记为false
* @param groupName
*/
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-rocketmq-all-4.1.0-incubating by lirenzuo.
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-rocketmq-all-4.1.0-incubating by lirenzuo.
the class SubscriptionGroupManager method deleteSubscriptionGroupConfig.
public void deleteSubscriptionGroupConfig(final String groupName) {
SubscriptionGroupConfig old = this.subscriptionGroupTable.remove(groupName);
if (old != null) {
log.info("delete subscription group OK, subscription group:{}", old);
this.dataVersion.nextVersion();
this.persist();
} else {
log.warn("delete subscription group failed, subscription groupName: {} not exist", groupName);
}
}
use of org.apache.rocketmq.common.subscription.SubscriptionGroupConfig in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class MQAdmin method getSubConnection.
public void getSubConnection(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 {
System.out.printf("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();
}
use of org.apache.rocketmq.common.subscription.SubscriptionGroupConfig in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
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