Search in sources :

Example 1 with GetConsumerConnectionListRequestHeader

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

the class AdminBrokerProcessor method getConsumerConnectionList.

private RemotingCommand getConsumerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetConsumerConnectionListRequestHeader requestHeader = (GetConsumerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetConsumerConnectionListRequestHeader.class);
    ConsumerGroupInfo consumerGroupInfo = this.brokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup());
    if (consumerGroupInfo != null) {
        ConsumerConnection bodydata = new ConsumerConnection();
        bodydata.setConsumeFromWhere(consumerGroupInfo.getConsumeFromWhere());
        bodydata.setConsumeType(consumerGroupInfo.getConsumeType());
        bodydata.setMessageModel(consumerGroupInfo.getMessageModel());
        bodydata.getSubscriptionTable().putAll(consumerGroupInfo.getSubscriptionTable());
        Iterator<Map.Entry<Channel, ClientChannelInfo>> it = consumerGroupInfo.getChannelInfoTable().entrySet().iterator();
        while (it.hasNext()) {
            ClientChannelInfo info = it.next().getValue();
            Connection connection = new Connection();
            connection.setClientId(info.getClientId());
            connection.setLanguage(info.getLanguage());
            connection.setVersion(info.getVersion());
            connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel()));
            bodydata.getConnectionSet().add(connection);
        }
        byte[] body = bodydata.encode();
        response.setBody(body);
        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);
        return response;
    }
    response.setCode(ResponseCode.CONSUMER_NOT_ONLINE);
    response.setRemark("the consumer group[" + requestHeader.getConsumerGroup() + "] not online");
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetConsumerConnectionListRequestHeader(org.apache.rocketmq.common.protocol.header.GetConsumerConnectionListRequestHeader) ClientChannelInfo(org.apache.rocketmq.broker.client.ClientChannelInfo) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) Connection(org.apache.rocketmq.common.protocol.body.Connection) ProducerConnection(org.apache.rocketmq.common.protocol.body.ProducerConnection) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) ConsumerGroupInfo(org.apache.rocketmq.broker.client.ConsumerGroupInfo)

Example 2 with GetConsumerConnectionListRequestHeader

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

the class MQClientAPIImpl method getConsumerConnectionList.

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

Example 3 with GetConsumerConnectionListRequestHeader

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

the class AdminBrokerProcessor method getConsumerConnectionList.

private RemotingCommand getConsumerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetConsumerConnectionListRequestHeader requestHeader = (GetConsumerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetConsumerConnectionListRequestHeader.class);
    ConsumerGroupInfo consumerGroupInfo = this.brokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup());
    if (consumerGroupInfo != null) {
        ConsumerConnection bodydata = new ConsumerConnection();
        bodydata.setConsumeFromWhere(consumerGroupInfo.getConsumeFromWhere());
        bodydata.setConsumeType(consumerGroupInfo.getConsumeType());
        bodydata.setMessageModel(consumerGroupInfo.getMessageModel());
        bodydata.getSubscriptionTable().putAll(consumerGroupInfo.getSubscriptionTable());
        Iterator<Map.Entry<Channel, ClientChannelInfo>> it = consumerGroupInfo.getChannelInfoTable().entrySet().iterator();
        while (it.hasNext()) {
            ClientChannelInfo info = it.next().getValue();
            Connection connection = new Connection();
            connection.setClientId(info.getClientId());
            connection.setLanguage(info.getLanguage());
            connection.setVersion(info.getVersion());
            connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel()));
            bodydata.getConnectionSet().add(connection);
        }
        byte[] body = bodydata.encode();
        response.setBody(body);
        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);
        return response;
    }
    response.setCode(ResponseCode.CONSUMER_NOT_ONLINE);
    response.setRemark("the consumer group[" + requestHeader.getConsumerGroup() + "] not online");
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetConsumerConnectionListRequestHeader(org.apache.rocketmq.common.protocol.header.GetConsumerConnectionListRequestHeader) ClientChannelInfo(org.apache.rocketmq.broker.client.ClientChannelInfo) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) Connection(org.apache.rocketmq.common.protocol.body.Connection) ProducerConnection(org.apache.rocketmq.common.protocol.body.ProducerConnection) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) ConsumerGroupInfo(org.apache.rocketmq.broker.client.ConsumerGroupInfo)

Example 4 with GetConsumerConnectionListRequestHeader

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

the class MQClientAPIImpl method getConsumerConnectionList.

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

Aggregations

ConsumerConnection (org.apache.rocketmq.common.protocol.body.ConsumerConnection)4 GetConsumerConnectionListRequestHeader (org.apache.rocketmq.common.protocol.header.GetConsumerConnectionListRequestHeader)4 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)4 ClientChannelInfo (org.apache.rocketmq.broker.client.ClientChannelInfo)2 ConsumerGroupInfo (org.apache.rocketmq.broker.client.ConsumerGroupInfo)2 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)2 Connection (org.apache.rocketmq.common.protocol.body.Connection)2 ProducerConnection (org.apache.rocketmq.common.protocol.body.ProducerConnection)2