Search in sources :

Example 6 with GetConsumerStatusRequestHeader

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

the class ClientRemotingProcessor method getConsumeStatus.

@Deprecated
public RemotingCommand getConsumeStatus(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetConsumerStatusRequestHeader requestHeader = (GetConsumerStatusRequestHeader) request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
    Map<MessageQueue, Long> offsetTable = this.mqClientFactory.getConsumerStatus(requestHeader.getTopic(), requestHeader.getGroup());
    GetConsumerStatusBody body = new GetConsumerStatusBody();
    body.setMessageQueueTable(offsetTable);
    response.setBody(body.encode());
    response.setCode(ResponseCode.SUCCESS);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) GetConsumerStatusBody(org.apache.rocketmq.common.protocol.body.GetConsumerStatusBody) GetConsumerStatusRequestHeader(org.apache.rocketmq.common.protocol.header.GetConsumerStatusRequestHeader)

Example 7 with GetConsumerStatusRequestHeader

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

the class MQClientAPIImpl method invokeBrokerToGetConsumerStatus.

public Map<String, Map<MessageQueue, Long>> invokeBrokerToGetConsumerStatus(final String addr, final String topic, final String group, final String clientAddr, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
    GetConsumerStatusRequestHeader requestHeader = new GetConsumerStatusRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setGroup(group);
    requestHeader.setClientAddr(clientAddr);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.INVOKE_BROKER_TO_GET_CONSUMER_STATUS, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                if (response.getBody() != null) {
                    GetConsumerStatusBody body = GetConsumerStatusBody.decode(response.getBody(), GetConsumerStatusBody.class);
                    return body.getConsumerTable();
                }
            }
        default:
            break;
    }
    throw new MQClientException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetConsumerStatusBody(org.apache.rocketmq.common.protocol.body.GetConsumerStatusBody) GetConsumerStatusRequestHeader(org.apache.rocketmq.common.protocol.header.GetConsumerStatusRequestHeader) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Example 8 with GetConsumerStatusRequestHeader

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

the class AdminBrokerProcessor method getConsumerStatus.

public RemotingCommand getConsumerStatus(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final GetConsumerStatusRequestHeader requestHeader = (GetConsumerStatusRequestHeader) request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
    log.info("[get-consumer-status] get consumer status by {}. topic={}, group={}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup());
    return this.brokerController.getBroker2Client().getConsumeStatus(requestHeader.getTopic(), requestHeader.getGroup(), requestHeader.getClientAddr());
}
Also used : GetConsumerStatusRequestHeader(org.apache.rocketmq.common.protocol.header.GetConsumerStatusRequestHeader)

Aggregations

GetConsumerStatusRequestHeader (org.apache.rocketmq.common.protocol.header.GetConsumerStatusRequestHeader)8 GetConsumerStatusBody (org.apache.rocketmq.common.protocol.body.GetConsumerStatusBody)6 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)6 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)4 Channel (io.netty.channel.Channel)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 ClientChannelInfo (org.apache.rocketmq.broker.client.ClientChannelInfo)2 MQClientException (org.apache.rocketmq.client.exception.MQClientException)2 RemotingSendRequestException (org.apache.rocketmq.remoting.exception.RemotingSendRequestException)2 RemotingTimeoutException (org.apache.rocketmq.remoting.exception.RemotingTimeoutException)2