paascloud/paascloud-master · error · TpcBizException

TPC100500013

TPC100500013

Error message

TPC100500013

What it means

TPC100500013 ("延迟级别错误, Topic=%s, MessageKey=%s") is thrown by RocketMqProducer.sendSimpleMessage when the supplied delayLevel is outside the valid RocketMQ range 0–18 (RocketMQ supports delay levels 1..18, 0 meaning no delay). The message is rejected before being handed to the producer.

Solutions

  1. Clamp or map your desired delay to a valid RocketMQ delay level 0–18 before calling sendSimpleMessage.
  2. Check the RocketMQ delay-level table (1s, 5s, 10s, 30s, 1m, ... 2h) and pick the closest level.
  3. If a larger delay is needed, use RocketMQ scheduled/timer message support or persist and poll instead of an invalid level.
  4. Validate delayLevel at the API boundary and return a 400-style error instead of relying on the producer throw.
  5. null is acceptable (treated as 0/no delay); avoid passing other sentinel values.

Example fix

// before: passing delay in seconds
RocketMqProducer.sendSimpleMessage(body, topic, tag, key, pid, 1800); // throws
// after: map to a valid level (0-18)
int delayLevel = mapToRocketMqLevel(Duration.ofMinutes(30)); // e.g. level 16
RocketMqProducer.sendSimpleMessage(body, topic, tag, key, pid, delayLevel);
Defensive patterns

Strategy: validation

Validate before calling

public static void checkDelayLevel(Integer delayLevel) {
    int lvl = delayLevel == null ? 0 : delayLevel;
    if (lvl < 0 || lvl > 18) {
        throw new IllegalArgumentException("delayLevel must be 0-18, got " + lvl);
    }
}

Type guard

boolean isValidDelayLevel(Integer l) { return l == null || (l >= 0 && l <= 18); }

Try / catch

try {
    RocketMqProducer.sendSimpleMessage(body, topic, tag, key, pid, delayLevel);
} catch (TpcBizException e) {
    if (e.getCode() == 10050013) {
        log.error("Invalid delayLevel {} for topic {}", delayLevel, topic);
        throw new BadRequestException("delayLevel out of range 0-18");
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling RocketMqProducer.sendSimpleMessage(body, topic, tag, key, pid, delayLevel) with a negative delayLevel or one greater than 18 (e.g. passing seconds/minutes instead of a level index, or a level from a different MQ's scheme).

Common situations: Mapping a business delay (e.g. 30 minutes) incorrectly to a level; RocketMQ level tables differing from RabbitMQ/ActiveMQ delay conventions; user input feeding delayLevel directly without clamping.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10). Data as JSON: /api/errors/dd6f638b4039b807. Report an issue: GitHub.

Appendix: source

Thrown at paascloud-provider/paascloud-provider-tpc/src/main/java/com/paascloud/provider/mq/RocketMqProducer.java:43

/**
 * The class Rocket mq producer.
 *
 * @author paascloud.net @gmail.com
 */
@Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class RocketMqProducer {

	private static final int PRODUCER_RETRY_TIMES = 3;

	public static SendResult sendSimpleMessage(String body, String topic, String tag, String key, String pid, Integer delayLevel) {
		if (delayLevel == null) {
			delayLevel = 0;
		}
		Message message = MqMessage.checkMessage(body, topic, tag, key);
		if (delayLevel < 0 || delayLevel > GlobalConstant.Number.EIGHTEEN_INT) {
			throw new TpcBizException(ErrorCodeEnum.TPC100500013, topic, key);
		}
		message.setDelayTimeLevel(delayLevel);
		return retrySendMessage(pid, message);
	}

	private static SendResult retrySendMessage(String pid, Message msg) {
		int iniCount = 1;
		SendResult result;
		while (true) {
			try {
				result = MqProducerBeanFactory.getBean(pid).send(msg);
				break;
			} catch (Exception e) {
				log.error("发送消息失败:", e);
				if (iniCount++ >= PRODUCER_RETRY_TIMES) {
					throw new TpcBizException(ErrorCodeEnum.TPC100500014, msg.getTopic(), msg.getKeys());
				}
			}

View on GitHub (pinned to 781281a950)