org.apache.rocketmq.common.subscription.SubscriptionGroupConfig Java Examples

The following examples show how to use org.apache.rocketmq.common.subscription.SubscriptionGroupConfig. 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: MQClientAPIImpl.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public void createSubscriptionGroup(final String addr, final SubscriptionGroupConfig config,
    final long timeoutMillis)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP, null);

    byte[] body = RemotingSerializable.encode(config);
    request.setBody(body);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            return;
        }
        default:
            break;
    }

    throw new MQClientException(response.getCode(), response.getRemark());

}
 
Example #2
Source File: MQClientAPIImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
public void createSubscriptionGroup(final String addr, final SubscriptionGroupConfig config,
    final long timeoutMillis)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP, null);

    byte[] body = RemotingSerializable.encode(config);
    request.setBody(body);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            return;
        }
        default:
            break;
    }

    throw new MQClientException(response.getCode(), response.getRemark());

}
 
Example #3
Source File: MQClientAPIImpl.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public void createSubscriptionGroup(final String addr, final SubscriptionGroupConfig config, final long timeoutMillis)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP, null);

    byte[] body = RemotingSerializable.encode(config);
    request.setBody(body);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            return;
        }
        default:
            break;
    }

    throw new MQClientException(response.getCode(), response.getRemark());

}
 
Example #4
Source File: MQClientAPIImpl.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
public void createSubscriptionGroup(final String addr, final SubscriptionGroupConfig config,
    final long timeoutMillis)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP, null);

    byte[] body = RemotingSerializable.encode(config);
    request.setBody(body);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            return;
        }
        default:
            break;
    }

    throw new MQClientException(response.getCode(), response.getRemark());

}
 
Example #5
Source File: SubscriptionGroupWrapperTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testFromJson(){
    SubscriptionGroupWrapper subscriptionGroupWrapper = new SubscriptionGroupWrapper();
    ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptions = new ConcurrentHashMap<String, SubscriptionGroupConfig>();
    SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
    subscriptionGroupConfig.setConsumeBroadcastEnable(true);
    subscriptionGroupConfig.setBrokerId(1234);
    subscriptionGroupConfig.setGroupName("Consumer-group-one");
    subscriptions.put("Consumer-group-one", subscriptionGroupConfig);
    subscriptionGroupWrapper.setSubscriptionGroupTable(subscriptions);
    DataVersion dataVersion = new DataVersion();
    dataVersion.nextVersion();
    subscriptionGroupWrapper.setDataVersion(dataVersion);
    String json = RemotingSerializable.toJson(subscriptionGroupWrapper, true);
    SubscriptionGroupWrapper fromJson = RemotingSerializable.fromJson(json, SubscriptionGroupWrapper.class);
    assertThat(fromJson.getSubscriptionGroupTable()).containsKey("Consumer-group-one");
    assertThat(fromJson.getSubscriptionGroupTable().get("Consumer-group-one").getGroupName()).isEqualTo("Consumer-group-one");
    assertThat(fromJson.getSubscriptionGroupTable().get("Consumer-group-one").getBrokerId()).isEqualTo(1234);
}
 
Example #6
Source File: MQClientAPIImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
public void createSubscriptionGroup(final String addr, final SubscriptionGroupConfig config,
    final long timeoutMillis)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP, null);

    byte[] body = RemotingSerializable.encode(config);
    request.setBody(body);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            return;
        }
        default:
            break;
    }

    throw new MQClientException(response.getCode(), response.getRemark());

}
 
Example #7
Source File: AdminBrokerProcessor.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
private RemotingCommand updateAndCreateSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request)
        throws RemotingCommandException {
        final RemotingCommand response = RemotingCommand.createResponseCommand(null);

        log.info("updateAndCreateSubscriptionGroup called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));

        SubscriptionGroupConfig config = RemotingSerializable.decode(request.getBody(), SubscriptionGroupConfig.class);
        if (config != null) {
//            =》
            this.brokerController.getSubscriptionGroupManager().updateSubscriptionGroupConfig(config);
        }

        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);
        return response;
    }
 
Example #8
Source File: MQClientAPIImpl.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
public void createSubscriptionGroup(final String addr, final SubscriptionGroupConfig config,
    final long timeoutMillis)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP, null);

    byte[] body = RemotingSerializable.encode(config);
    request.setBody(body);

    String acturallyAddr = getActurallyBrokerAddr(addr);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), acturallyAddr),
        request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            return;
        }
        default:
            break;
    }

    throw new MQClientException(response.getCode(), response.getRemark());

}
 
Example #9
Source File: SubscriptionGroupManager.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #10
Source File: SubscriptionGroupManager.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private void printLoadDataWhenFirstBoot(final SubscriptionGroupManager sgm) {
    Iterator<Entry<String, SubscriptionGroupConfig>> it = sgm.getSubscriptionGroupTable().entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, SubscriptionGroupConfig> next = it.next();
        log.info("load exist subscription group, {}", next.getValue().toString());
    }
}
 
Example #11
Source File: SubscriptionGroupManager.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
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);
        }
    }
 
Example #12
Source File: SubscriptionGroupManager.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #13
Source File: AdminBrokerProcessor.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private RemotingCommand updateAndCreateSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request)
    throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);

    log.info("updateAndCreateSubscriptionGroup called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));

    SubscriptionGroupConfig config = RemotingSerializable.decode(request.getBody(), SubscriptionGroupConfig.class);
    if (config != null) {
        this.brokerController.getSubscriptionGroupManager().updateSubscriptionGroupConfig(config);
    }

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
Example #14
Source File: SubscriptionGroupManager.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
private void printLoadDataWhenFirstBoot(final SubscriptionGroupManager sgm) {
    Iterator<Entry<String, SubscriptionGroupConfig>> it = sgm.getSubscriptionGroupTable().entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, SubscriptionGroupConfig> next = it.next();
        log.info("load exist subscription group, {}", next.getValue().toString());
    }
}
 
Example #15
Source File: AdminBrokerProcessor.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private RemotingCommand updateAndCreateSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request)
    throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);

    log.info("updateAndCreateSubscriptionGroup called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));

    SubscriptionGroupConfig config = RemotingSerializable.decode(request.getBody(), SubscriptionGroupConfig.class);
    if (config != null) {
        this.brokerController.getSubscriptionGroupManager().updateSubscriptionGroupConfig(config);
    }

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
Example #16
Source File: SubscriptionGroupManager.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #17
Source File: SubscriptionGroupManager.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
public void disableConsume(final String groupName) {
//        消费组订阅信息
        SubscriptionGroupConfig old = this.subscriptionGroupTable.get(groupName);
        if (old != null) {
//            设置禁止消费
            old.setConsumeEnable(false);
            this.dataVersion.nextVersion();
        }
    }
 
Example #18
Source File: SubscriptionGroupManager.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private void printLoadDataWhenFirstBoot(final SubscriptionGroupManager sgm) {
    Iterator<Entry<String, SubscriptionGroupConfig>> it = sgm.getSubscriptionGroupTable().entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, SubscriptionGroupConfig> next = it.next();
        log.info("load exist subscription group, {}", next.getValue().toString());
    }
}
 
Example #19
Source File: SubscriptionGroupManager.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #20
Source File: SubscriptionGroupManager.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #21
Source File: SubscriptionGroupManager.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
public void disableConsume(final String groupName) {
    SubscriptionGroupConfig old = this.subscriptionGroupTable.get(groupName);
    if (old != null) {
        old.setConsumeEnable(false);
        this.dataVersion.nextVersion();
    }
}
 
Example #22
Source File: SubscriptionGroupManager.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
/**
 * 跟新消费组的消费信息并持久化
 * @param config config
 */
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();
}
 
Example #23
Source File: SubscriptionGroupManager.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public void disableConsume(final String groupName) {
    SubscriptionGroupConfig old = this.subscriptionGroupTable.get(groupName);
    if (old != null) {
        old.setConsumeEnable(false);
        this.dataVersion.nextVersion();
    }
}
 
Example #24
Source File: SubscriptionGroupManager.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
private void printLoadDataWhenFirstBoot(final SubscriptionGroupManager sgm) {
    Iterator<Entry<String, SubscriptionGroupConfig>> it = sgm.getSubscriptionGroupTable().entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, SubscriptionGroupConfig> next = it.next();
        log.info("load exist subscription group, {}", next.getValue().toString());
    }
}
 
Example #25
Source File: SubscriptionGroupManager.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
/**
 * 删除消费组
 * @param groupName ;
 */
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);
    }
}
 
Example #26
Source File: SubscriptionGroupManager.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
private void printLoadDataWhenFirstBoot(final SubscriptionGroupManager sgm) {
    Iterator<Entry<String, SubscriptionGroupConfig>> it = sgm.getSubscriptionGroupTable().entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, SubscriptionGroupConfig> next = it.next();
        log.info("load exist subscription group, {}", next.getValue().toString());
    }
}
 
Example #27
Source File: SubscriptionGroupManager.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #28
Source File: SubscriptionGroupManager.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private void printLoadDataWhenFirstBoot(final SubscriptionGroupManager sgm) {
    Iterator<Entry<String, SubscriptionGroupConfig>> it = sgm.getSubscriptionGroupTable().entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, SubscriptionGroupConfig> next = it.next();
        log.info("load exist subscription group, {}", next.getValue().toString());
    }
}
 
Example #29
Source File: SubscriptionGroupManager.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #30
Source File: AdminBrokerProcessor.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
private RemotingCommand updateAndCreateSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request)
    throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);

    log.info("updateAndCreateSubscriptionGroup called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));

    SubscriptionGroupConfig config = RemotingSerializable.decode(request.getBody(), SubscriptionGroupConfig.class);
    if (config != null) {
        this.brokerController.getSubscriptionGroupManager().updateSubscriptionGroupConfig(config);
    }

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}