Search in sources :

Example 21 with MQClientException

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

the class MQClientAPIImpl method getUnitTopicList.

public TopicList getUnitTopicList(final boolean containRetry, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_UNIT_TOPIC_LIST, null);
    RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                byte[] body = response.getBody();
                if (body != null) {
                    TopicList topicList = TopicList.decode(response.getBody(), TopicList.class);
                    if (!containRetry) {
                        Iterator<String> it = topicList.getTopicList().iterator();
                        while (it.hasNext()) {
                            String topic = it.next();
                            if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX))
                                it.remove();
                        }
                    }
                    return topicList;
                }
            }
        default:
            break;
    }
    throw new MQClientException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) Iterator(java.util.Iterator) TopicList(org.apache.rocketmq.common.protocol.body.TopicList) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Example 22 with MQClientException

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

the class MQClientAPIImpl method consumeMessageDirectly.

public ConsumeMessageDirectlyResult consumeMessageDirectly(final String addr, String consumerGroup, String clientId, String msgId, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
    ConsumeMessageDirectlyResultRequestHeader requestHeader = new ConsumeMessageDirectlyResultRequestHeader();
    requestHeader.setConsumerGroup(consumerGroup);
    requestHeader.setClientId(clientId);
    requestHeader.setMsgId(msgId);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CONSUME_MESSAGE_DIRECTLY, 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) {
                    ConsumeMessageDirectlyResult info = ConsumeMessageDirectlyResult.decode(body, ConsumeMessageDirectlyResult.class);
                    return info;
                }
            }
        default:
            break;
    }
    throw new MQClientException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) ConsumeMessageDirectlyResult(org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult) ConsumeMessageDirectlyResultRequestHeader(org.apache.rocketmq.common.protocol.header.ConsumeMessageDirectlyResultRequestHeader) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Example 23 with MQClientException

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

the class MQClientAPIImpl method cleanExpiredConsumeQueue.

public boolean cleanExpiredConsumeQueue(final String addr, long timeoutMillis) throws MQClientException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CLEAN_EXPIRED_CONSUMEQUEUE, null);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                return true;
            }
        default:
            break;
    }
    throw new MQClientException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Example 24 with MQClientException

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

the class MQClientAPIImpl method getHasUnitSubTopicList.

public TopicList getHasUnitSubTopicList(final boolean containRetry, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_HAS_UNIT_SUB_TOPIC_LIST, null);
    RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                byte[] body = response.getBody();
                if (body != null) {
                    TopicList topicList = TopicList.decode(response.getBody(), TopicList.class);
                    if (!containRetry) {
                        Iterator<String> it = topicList.getTopicList().iterator();
                        while (it.hasNext()) {
                            String topic = it.next();
                            if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX))
                                it.remove();
                        }
                    }
                    return topicList;
                }
            }
        default:
            break;
    }
    throw new MQClientException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) Iterator(java.util.Iterator) TopicList(org.apache.rocketmq.common.protocol.body.TopicList) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Example 25 with MQClientException

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

the class MQClientAPIImpl method fetchConsumeStatsInBroker.

public ConsumeStatsList fetchConsumeStatsInBroker(String brokerAddr, boolean isOrder, long timeoutMillis) throws MQClientException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
    GetConsumeStatsInBrokerHeader requestHeader = new GetConsumeStatsInBrokerHeader();
    requestHeader.setIsOrder(isOrder);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_CONSUME_STATS, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), brokerAddr), request, timeoutMillis);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                byte[] body = response.getBody();
                if (body != null) {
                    return ConsumeStatsList.decode(body, ConsumeStatsList.class);
                }
            }
        default:
            break;
    }
    throw new MQClientException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) ConsumeStatsList(org.apache.rocketmq.common.protocol.body.ConsumeStatsList) GetConsumeStatsInBrokerHeader(org.apache.rocketmq.common.protocol.header.GetConsumeStatsInBrokerHeader) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Aggregations

MQClientException (org.apache.rocketmq.client.exception.MQClientException)230 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)70 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)69 RemotingException (org.apache.rocketmq.remoting.exception.RemotingException)65 Message (org.apache.rocketmq.common.message.Message)35 SendResult (org.apache.rocketmq.client.producer.SendResult)34 DefaultMQProducer (org.apache.rocketmq.client.producer.DefaultMQProducer)29 MessageExt (org.apache.rocketmq.common.message.MessageExt)25 UnsupportedEncodingException (java.io.UnsupportedEncodingException)18 SubscriptionData (org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData)18 DefaultMQPushConsumer (org.apache.rocketmq.client.consumer.DefaultMQPushConsumer)17 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)17 RemotingCommandException (org.apache.rocketmq.remoting.exception.RemotingCommandException)17 PullResult (org.apache.rocketmq.client.consumer.PullResult)16 TopicList (org.apache.rocketmq.common.protocol.body.TopicList)16 MessageListenerConcurrently (org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently)15 TopicRouteData (org.apache.rocketmq.common.protocol.route.TopicRouteData)15 BrokerData (org.apache.rocketmq.common.protocol.route.BrokerData)14 ConsumeConcurrentlyContext (org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext)11 ConsumeConcurrentlyStatus (org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus)11