Search in sources :

Example 1 with GetConsumerRunningInfoRequestHeader

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

the class MQClientAPIImpl method getConsumerRunningInfo.

public ConsumerRunningInfo getConsumerRunningInfo(final String addr, String consumerGroup, String clientId, boolean jstack, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
    GetConsumerRunningInfoRequestHeader requestHeader = new GetConsumerRunningInfoRequestHeader();
    requestHeader.setConsumerGroup(consumerGroup);
    requestHeader.setClientId(clientId);
    requestHeader.setJstackEnable(jstack);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_RUNNING_INFO, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                byte[] body = response.getBody();
                if (body != null) {
                    ConsumerRunningInfo info = ConsumerRunningInfo.decode(body, ConsumerRunningInfo.class);
                    return info;
                }
            }
        default:
            break;
    }
    throw new MQClientException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) ConsumerRunningInfo(org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo) GetConsumerRunningInfoRequestHeader(org.apache.rocketmq.common.protocol.header.GetConsumerRunningInfoRequestHeader) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Example 2 with GetConsumerRunningInfoRequestHeader

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

the class ClientRemotingProcessor method getConsumerRunningInfo.

private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetConsumerRunningInfoRequestHeader requestHeader = (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
    ConsumerRunningInfo consumerRunningInfo = this.mqClientFactory.consumerRunningInfo(requestHeader.getConsumerGroup());
    if (null != consumerRunningInfo) {
        if (requestHeader.isJstackEnable()) {
            Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
            String jstack = UtilAll.jstack(map);
            consumerRunningInfo.setJstack(jstack);
        }
        response.setCode(ResponseCode.SUCCESS);
        response.setBody(consumerRunningInfo.encode());
    } else {
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup()));
    }
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) ConsumerRunningInfo(org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo) GetConsumerRunningInfoRequestHeader(org.apache.rocketmq.common.protocol.header.GetConsumerRunningInfoRequestHeader)

Example 3 with GetConsumerRunningInfoRequestHeader

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

the class ClientRemotingProcessor method getConsumerRunningInfo.

private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetConsumerRunningInfoRequestHeader requestHeader = (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
    ConsumerRunningInfo consumerRunningInfo = this.mqClientFactory.consumerRunningInfo(requestHeader.getConsumerGroup());
    if (null != consumerRunningInfo) {
        if (requestHeader.isJstackEnable()) {
            Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
            String jstack = UtilAll.jstack(map);
            consumerRunningInfo.setJstack(jstack);
        }
        response.setCode(ResponseCode.SUCCESS);
        response.setBody(consumerRunningInfo.encode());
    } else {
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup()));
    }
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) ConsumerRunningInfo(org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo) GetConsumerRunningInfoRequestHeader(org.apache.rocketmq.common.protocol.header.GetConsumerRunningInfoRequestHeader)

Example 4 with GetConsumerRunningInfoRequestHeader

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

the class MQClientAPIImpl method getConsumerRunningInfo.

public ConsumerRunningInfo getConsumerRunningInfo(final String addr, String consumerGroup, String clientId, boolean jstack, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
    GetConsumerRunningInfoRequestHeader requestHeader = new GetConsumerRunningInfoRequestHeader();
    requestHeader.setConsumerGroup(consumerGroup);
    requestHeader.setClientId(clientId);
    requestHeader.setJstackEnable(jstack);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_RUNNING_INFO, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                byte[] body = response.getBody();
                if (body != null) {
                    ConsumerRunningInfo info = ConsumerRunningInfo.decode(body, ConsumerRunningInfo.class);
                    return info;
                }
            }
        default:
            break;
    }
    throw new MQClientException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) ConsumerRunningInfo(org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo) GetConsumerRunningInfoRequestHeader(org.apache.rocketmq.common.protocol.header.GetConsumerRunningInfoRequestHeader) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Aggregations

ConsumerRunningInfo (org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo)4 GetConsumerRunningInfoRequestHeader (org.apache.rocketmq.common.protocol.header.GetConsumerRunningInfoRequestHeader)4 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)4 MQClientException (org.apache.rocketmq.client.exception.MQClientException)2