Search in sources :

Example 41 with MQBrokerException

use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq by apache.

the class MQClientAPIImpl method getAllSubscriptionGroup.

public SubscriptionGroupWrapper getAllSubscriptionGroup(final String brokerAddr, long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_SUBSCRIPTIONGROUP_CONFIG, null);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), brokerAddr), request, timeoutMillis);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                return SubscriptionGroupWrapper.decode(response.getBody(), SubscriptionGroupWrapper.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) SubscriptionGroupWrapper(org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper)

Example 42 with MQBrokerException

use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq by apache.

the class MQClientAPIImpl method getTopicStatsInfo.

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

Example 43 with MQBrokerException

use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq by apache.

the class MQClientAPIImpl method getMinOffset.

public long getMinOffset(final String addr, final String topic, final int queueId, final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
    GetMinOffsetRequestHeader requestHeader = new GetMinOffsetRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setQueueId(queueId);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_MIN_OFFSET, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                GetMinOffsetResponseHeader responseHeader = (GetMinOffsetResponseHeader) response.decodeCommandCustomHeader(GetMinOffsetResponseHeader.class);
                return responseHeader.getOffset();
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetMinOffsetRequestHeader(org.apache.rocketmq.common.protocol.header.GetMinOffsetRequestHeader) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) GetMinOffsetResponseHeader(org.apache.rocketmq.common.protocol.header.GetMinOffsetResponseHeader)

Example 44 with MQBrokerException

use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq by apache.

the class MQClientAPIImpl method unregisterClient.

public void unregisterClient(final String addr, final String clientID, final String producerGroup, final String consumerGroup, final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
    final UnregisterClientRequestHeader requestHeader = new UnregisterClientRequestHeader();
    requestHeader.setClientID(clientID);
    requestHeader.setProducerGroup(producerGroup);
    requestHeader.setConsumerGroup(consumerGroup);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNREGISTER_CLIENT, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(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) UnregisterClientRequestHeader(org.apache.rocketmq.common.protocol.header.UnregisterClientRequestHeader) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException)

Example 45 with MQBrokerException

use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq by apache.

the class MQClientAPIImpl method getBrokerRuntimeInfo.

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

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