Search in sources :

Example 11 with MQBrokerException

use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class MQClientAPIImpl method getAllTopicConfig.

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

Example 12 with MQBrokerException

use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class MQClientAPIImpl method getConsumerIdListByGroup.

public // 
List<String> getConsumerIdListByGroup(// 
final String addr, // 
final String consumerGroup, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, MQBrokerException, InterruptedException {
    GetConsumerListByGroupRequestHeader requestHeader = new GetConsumerListByGroupRequestHeader();
    requestHeader.setConsumerGroup(consumerGroup);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_LIST_BY_GROUP, 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) {
                    GetConsumerListByGroupResponseBody body = GetConsumerListByGroupResponseBody.decode(response.getBody(), GetConsumerListByGroupResponseBody.class);
                    return body.getConsumerIdList();
                }
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetConsumerListByGroupResponseBody(org.apache.rocketmq.common.protocol.header.GetConsumerListByGroupResponseBody) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) GetConsumerListByGroupRequestHeader(org.apache.rocketmq.common.protocol.header.GetConsumerListByGroupRequestHeader)

Example 13 with MQBrokerException

use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class MQClientAPIImpl method updateConsumerOffset.

public // 
void updateConsumerOffset(// 
final String addr, // 
final UpdateConsumerOffsetRequestHeader requestHeader, // 
final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_CONSUMER_OFFSET, requestHeader);
    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 MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException)

Example 14 with MQBrokerException

use of org.apache.rocketmq.client.exception.MQBrokerException 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 15 with MQBrokerException

use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class MQClientAPIImpl method queryConsumeTimeSpan.

public List<QueueTimeSpan> queryConsumeTimeSpan(final String addr, final String topic, final String group, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException {
    QueryConsumeTimeSpanRequestHeader requestHeader = new QueryConsumeTimeSpanRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setGroup(group);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUME_TIME_SPAN, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                QueryConsumeTimeSpanBody consumeTimeSpanBody = GroupList.decode(response.getBody(), QueryConsumeTimeSpanBody.class);
                return consumeTimeSpanBody.getConsumeTimeSpanSet();
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) QueryConsumeTimeSpanBody(org.apache.rocketmq.common.protocol.body.QueryConsumeTimeSpanBody) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) QueryConsumeTimeSpanRequestHeader(org.apache.rocketmq.common.protocol.header.QueryConsumeTimeSpanRequestHeader)

Aggregations

MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)116 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)70 MQClientException (org.apache.rocketmq.client.exception.MQClientException)40 RemotingException (org.apache.rocketmq.remoting.exception.RemotingException)35 Message (org.apache.rocketmq.common.message.Message)12 SendResult (org.apache.rocketmq.client.producer.SendResult)11 RemotingConnectException (org.apache.rocketmq.remoting.exception.RemotingConnectException)11 RemotingTimeoutException (org.apache.rocketmq.remoting.exception.RemotingTimeoutException)11 UnsupportedEncodingException (java.io.UnsupportedEncodingException)10 SubCommandException (org.apache.rocketmq.tools.command.SubCommandException)10 RemotingSendRequestException (org.apache.rocketmq.remoting.exception.RemotingSendRequestException)9 Test (org.junit.Test)9 MessageExt (org.apache.rocketmq.common.message.MessageExt)8 DefaultMQProducer (org.apache.rocketmq.client.producer.DefaultMQProducer)6 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)6 ConsumerConnection (org.apache.rocketmq.common.protocol.body.ConsumerConnection)6 GroupList (org.apache.rocketmq.common.protocol.body.GroupList)6 SubscriptionData (org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData)6 BrokerData (org.apache.rocketmq.common.protocol.route.BrokerData)6 IOException (java.io.IOException)5