Search in sources :

Example 1 with QueryTopicConsumeByWhoRequestHeader

use of org.apache.rocketmq.common.protocol.header.QueryTopicConsumeByWhoRequestHeader in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class MQClientAPIImpl method queryTopicConsumeByWho.

public GroupList queryTopicConsumeByWho(final String addr, final String topic, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException {
    QueryTopicConsumeByWhoRequestHeader requestHeader = new QueryTopicConsumeByWhoRequestHeader();
    requestHeader.setTopic(topic);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_TOPIC_CONSUME_BY_WHO, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                GroupList groupList = GroupList.decode(response.getBody(), GroupList.class);
                return groupList;
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GroupList(org.apache.rocketmq.common.protocol.body.GroupList) QueryTopicConsumeByWhoRequestHeader(org.apache.rocketmq.common.protocol.header.QueryTopicConsumeByWhoRequestHeader) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException)

Example 2 with QueryTopicConsumeByWhoRequestHeader

use of org.apache.rocketmq.common.protocol.header.QueryTopicConsumeByWhoRequestHeader in project rocketmq by apache.

the class AdminBrokerProcessor method queryTopicConsumeByWho.

private RemotingCommand queryTopicConsumeByWho(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    QueryTopicConsumeByWhoRequestHeader requestHeader = (QueryTopicConsumeByWhoRequestHeader) request.decodeCommandCustomHeader(QueryTopicConsumeByWhoRequestHeader.class);
    HashSet<String> groups = this.brokerController.getConsumerManager().queryTopicConsumeByWho(requestHeader.getTopic());
    Set<String> groupInOffset = this.brokerController.getConsumerOffsetManager().whichGroupByTopic(requestHeader.getTopic());
    if (groupInOffset != null && !groupInOffset.isEmpty()) {
        groups.addAll(groupInOffset);
    }
    GroupList groupList = new GroupList();
    groupList.setGroupList(groups);
    byte[] body = groupList.encode();
    response.setBody(body);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GroupList(org.apache.rocketmq.common.protocol.body.GroupList) QueryTopicConsumeByWhoRequestHeader(org.apache.rocketmq.common.protocol.header.QueryTopicConsumeByWhoRequestHeader)

Example 3 with QueryTopicConsumeByWhoRequestHeader

use of org.apache.rocketmq.common.protocol.header.QueryTopicConsumeByWhoRequestHeader in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class AdminBrokerProcessor method queryTopicConsumeByWho.

private RemotingCommand queryTopicConsumeByWho(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    QueryTopicConsumeByWhoRequestHeader requestHeader = (QueryTopicConsumeByWhoRequestHeader) request.decodeCommandCustomHeader(QueryTopicConsumeByWhoRequestHeader.class);
    HashSet<String> groups = this.brokerController.getConsumerManager().queryTopicConsumeByWho(requestHeader.getTopic());
    Set<String> groupInOffset = this.brokerController.getConsumerOffsetManager().whichGroupByTopic(requestHeader.getTopic());
    if (groupInOffset != null && !groupInOffset.isEmpty()) {
        groups.addAll(groupInOffset);
    }
    GroupList groupList = new GroupList();
    groupList.setGroupList(groups);
    byte[] body = groupList.encode();
    response.setBody(body);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GroupList(org.apache.rocketmq.common.protocol.body.GroupList) QueryTopicConsumeByWhoRequestHeader(org.apache.rocketmq.common.protocol.header.QueryTopicConsumeByWhoRequestHeader)

Example 4 with QueryTopicConsumeByWhoRequestHeader

use of org.apache.rocketmq.common.protocol.header.QueryTopicConsumeByWhoRequestHeader in project rocketmq by apache.

the class MQClientAPIImpl method queryTopicConsumeByWho.

public GroupList queryTopicConsumeByWho(final String addr, final String topic, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException {
    QueryTopicConsumeByWhoRequestHeader requestHeader = new QueryTopicConsumeByWhoRequestHeader();
    requestHeader.setTopic(topic);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_TOPIC_CONSUME_BY_WHO, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                GroupList groupList = GroupList.decode(response.getBody(), GroupList.class);
                return groupList;
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GroupList(org.apache.rocketmq.common.protocol.body.GroupList) QueryTopicConsumeByWhoRequestHeader(org.apache.rocketmq.common.protocol.header.QueryTopicConsumeByWhoRequestHeader) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException)

Aggregations

GroupList (org.apache.rocketmq.common.protocol.body.GroupList)4 QueryTopicConsumeByWhoRequestHeader (org.apache.rocketmq.common.protocol.header.QueryTopicConsumeByWhoRequestHeader)4 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)4 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)2