Search in sources :

Example 81 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 unlockBatchMQ.

public // 
void unlockBatchMQ(// 
final String addr, // 
final UnlockBatchRequestBody requestBody, // 
final long timeoutMillis, // 
final boolean oneway) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNLOCK_BATCH_MQ, null);
    request.setBody(requestBody.encode());
    if (oneway) {
        this.remotingClient.invokeOneway(addr, request, timeoutMillis);
    } else {
        RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
        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 82 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 queryConsumerOffset.

public // 
long queryConsumerOffset(// 
final String addr, // 
final QueryConsumerOffsetRequestHeader requestHeader, // 
final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_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:
            {
                QueryConsumerOffsetResponseHeader responseHeader = (QueryConsumerOffsetResponseHeader) response.decodeCommandCustomHeader(QueryConsumerOffsetResponseHeader.class);
                return responseHeader.getOffset();
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) QueryConsumerOffsetResponseHeader(org.apache.rocketmq.common.protocol.header.QueryConsumerOffsetResponseHeader) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException)

Example 83 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 lockBatchMQ.

public // 
Set<MessageQueue> lockBatchMQ(// 
final String addr, // 
final LockBatchRequestBody requestBody, final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.LOCK_BATCH_MQ, null);
    request.setBody(requestBody.encode());
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                LockBatchResponseBody responseBody = LockBatchResponseBody.decode(response.getBody(), LockBatchResponseBody.class);
                Set<MessageQueue> messageQueues = responseBody.getLockOKMQSet();
                return messageQueues;
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) Set(java.util.Set) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) LockBatchResponseBody(org.apache.rocketmq.common.protocol.body.LockBatchResponseBody)

Example 84 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 getBrokerClusterInfo.

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

Example 85 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 getMaxOffset.

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

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