use of com.ecfront.dew.common.exception.RTUnsupportedEncodingException in project dew by gudaoxuri.
the class RocketClusterMQ method doPublish.
@Override
protected boolean doPublish(String topic, String message, Optional<Map<String, Object>> header, boolean confirm) {
RocketMQTemplate rocketMQTemplate = rocketAdapter.getRocketMQTemplate();
Object funResult = null;
if (confirm) {
throw new RTUnsupportedEncodingException("Rocket doesn't support confirm mode");
}
try {
Map<String, Object> sendHeader = getMQHeader(topic);
header.ifPresent(sendHeader::putAll);
Message<?> msg = MessageBuilder.withPayload(message).copyHeaders(sendHeader).build();
funResult = sendBeforeFun.invoke(topic, sendHeader);
rocketMQTemplate.syncSend(topic, msg);
return true;
} catch (Exception e) {
logger.error("[MQ] Rocket publish error.", e);
sendErrorFun.invoke(e, funResult);
return false;
} finally {
sendFinishFun.invoke(funResult);
}
}
use of com.ecfront.dew.common.exception.RTUnsupportedEncodingException in project dew by gudaoxuri.
the class RocketClusterMQ method doRequest.
@Override
protected boolean doRequest(String address, String message, Optional<Map<String, Object>> header, boolean confirm) {
RocketMQTemplate rocketMQTemplate = rocketAdapter.getRocketMQTemplate();
Object funResult = null;
if (confirm) {
throw new RTUnsupportedEncodingException("Rocket doesn't support confirm mode");
}
try {
Map<String, Object> sendHeader = getMQHeader(address);
header.ifPresent(sendHeader::putAll);
funResult = sendBeforeFun.invoke(address, sendHeader);
Message<?> msg = MessageBuilder.withPayload(message).copyHeaders(sendHeader).build();
rocketMQTemplate.syncSend(address, msg);
return true;
} catch (Exception e) {
logger.error("[MQ] Rocket publish error.", e);
sendErrorFun.invoke(e, funResult);
return false;
} finally {
sendFinishFun.invoke(funResult);
}
}
Aggregations