private SendResult syncSend()

in rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/core/RocketMQTemplate.java [631:664]


    private SendResult syncSend(String destination, Message<?> message, long timeout, long delayTime, DelayMode mode) {
        if (Objects.isNull(message) || Objects.isNull(message.getPayload())) {
            log.error("syncSend failed. destination:{}, message is null ", destination);
            throw new IllegalArgumentException("`message` and `message.payload` cannot be null");
        }
        try {
            long now = System.currentTimeMillis();
            org.apache.rocketmq.common.message.Message rocketMsg = this.createRocketMqMessage(destination, message);
            if (delayTime > 0 && Objects.nonNull(mode)) {
                switch (mode) {
                    case DELAY_SECONDS:
                        rocketMsg.setDelayTimeSec(delayTime);
                        break;
                    case DELAY_MILLISECONDS:
                        rocketMsg.setDelayTimeMs(delayTime);
                        break;
                    case DELIVER_TIME_MILLISECONDS:
                        rocketMsg.setDeliverTimeMs(delayTime);
                        break;
                    default:
                        log.warn("delay mode: {} not support", mode);
                }
            }
            SendResult sendResult = producer.send(rocketMsg, timeout);
            long costTime = System.currentTimeMillis() - now;
            if (log.isDebugEnabled()) {
                log.debug("send message cost: {} ms, msgId:{}", costTime, sendResult.getMsgId());
            }
            return sendResult;
        } catch (Exception e) {
            log.error("syncSend failed. destination:{}, message:{}, detail exception info: ", destination, message, e);
            throw new MessagingException(e.getMessage(), e);
        }
    }