in ons-core/ons-client/src/main/java/org/apache/rocketmq/ons/api/impl/rocketmq/ProducerImpl.java [222:251]
private ONSClientException checkProducerException(String topic, String msgId, Throwable e) {
if (e instanceof MQClientException) {
if (e.getCause() != null) {
if (e.getCause() instanceof RemotingConnectException) {
return new ONSClientException(
FAQ.errorMessage(String.format("Connect broker failed, Topic=%s, msgId=%s", topic, msgId), FAQ.CONNECT_BROKER_FAILED));
} else if (e.getCause() instanceof RemotingTimeoutException) {
return new ONSClientException(FAQ.errorMessage(String.format("Send message to broker timeout, %dms, Topic=%s, msgId=%s",
this.defaultMQProducer.getSendMsgTimeout(), topic, msgId), FAQ.SEND_MSG_TO_BROKER_TIMEOUT));
} else if (e.getCause() instanceof MQBrokerException) {
MQBrokerException excep = (MQBrokerException) e.getCause();
return new ONSClientException(FAQ.errorMessage(
String.format("Receive a broker exception, Topic=%s, msgId=%s, %s", topic, msgId, excep.getErrorMessage()),
FAQ.BROKER_RESPONSE_EXCEPTION));
}
} else {
MQClientException excep = (MQClientException) e;
if (-1 == excep.getResponseCode()) {
return new ONSClientException(
FAQ.errorMessage(String.format("Topic does not exist, Topic=%s, msgId=%s", topic, msgId), FAQ.TOPIC_ROUTE_NOT_EXIST));
} else if (ResponseCode.MESSAGE_ILLEGAL == excep.getResponseCode()) {
return new ONSClientException(
FAQ.errorMessage(String.format("ONS Client check message exception, Topic=%s, msgId=%s", topic, msgId),
FAQ.CLIENT_CHECK_MSG_EXCEPTION));
}
}
}
return new ONSClientException("defaultMQProducer send exception", e);
}