Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 2023. x delayed message attribute TIMER_DELAY_SEC of spring cloud starter stream rocketMQ is not effective #3829

Closed
yanglei1980 opened this issue Aug 20, 2024 · 6 comments

Comments

@yanglei1980
Copy link

yanglei1980 commented Aug 20, 2024

spring-cloud-starter-stream-rocketmq 2023.x

Describe the bug

Message<String> message = MessageBuilder.withPayload(msg)
        .setHeader("TIMER_DELAY_SEC", 10)
        .build();

boolean sendResult = streamBridge.send("delaytest", message);

spring-cloud-starter-stream-rocketmq 2023.x is not effective

RocketMQMessageConverterSupport.getAndWrapMessage

headers.entrySet().stream()
	.filter(entry -> !Objects.equals(entry.getKey(), Headers.FLAG))
	.forEach(entry -> {
		if (!MessageConst.STRING_HASH_SET.contains(entry.getKey())) {
			String val = String.valueOf(entry.getValue());
			// Remove All blank header(rocketmq not support).
			if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
				rocketMsg.putUserProperty(entry.getKey(), val);
			}
		}
	});

Because in the 5. x version of RocketMQ Common, the messageConst The value of STRING_HASH_SET includes "TIMER_DELAY_SEC", so it is filtered out.

public static final String PROPERTY_TIMER_DELAY_SEC = "TIMER_DELAY_SEC";
public static final String PROPERTY_TIMER_DELIVER_MS = "TIMER_DELIVER_MS";
public static final String PROPERTY_BORN_HOST = "__BORNHOST";
public static final String PROPERTY_BORN_TIMESTAMP = "BORN_TIMESTAMP";

STRING_HASH_SET.add(PROPERTY_TIMER_DELAY_MS);
STRING_HASH_SET.add(PROPERTY_TIMER_DELAY_SEC);
STRING_HASH_SET.add(PROPERTY_TIMER_DELIVER_MS);

In version 4.9. x of rocketmq-common, messageConst The value of STRING_HASH_SET does not include 'TIMER_DELAY_SEC', so it is not filtered, spring-cloud-starter-stream-rocketmq 2021.x is effective

Copy link

This issue has been open 30 days with no activity. This will be closed in 7 days.

@github-actions github-actions bot added the stale label Sep 24, 2024
Copy link

github-actions bot commented Oct 2, 2024

This issue has been automatically marked as stale because it hasn't had any recent activity.If you think this should still be open, or the problem still persists, just pop a reply in the comments and one of the maintainers will (try!) to follow up. Thank you for your interest and contribution to the Sping Cloud Alibaba Community.

@dyrnq
Copy link

dyrnq commented Oct 16, 2024

@yanglei1980 same problem, How did you solve it?

@yanglei1980
Copy link
Author

@yanglei1980 same problem, How did you solve it?

DELAY_1S(1, "1s"),
DELAY_5S(2, "5s"),
DELAY_10S(3, "10s"),
DELAY_30S(4, "30s"),
DELAY_1MIN(5, "1min"),
DELAY_2MIN(6, "2min"),
DELAY_3MIN(7, "3min"),
DELAY_4MIN(8, "4min"),
DELAY_5MIN(9, "5min"),
DELAY_6MIN(10, "6min"),
DELAY_7MIN(11, "7min"),
DELAY_8MIN(12, "8min"),
DELAY_9MIN(13, "9min"),
DELAY_10MIN(14, "10min"),
DELAY_20MIN(15, "20min"),
DELAY_30MIN(16, "30min"),
DELAY_1H(17, "1h"),
DELAY_2H(18, "2h"),

Message message = MessageBuilder.withPayload(msg)
.setHeader(MessageConst.PROPERTY_TAGS, tag)
.setHeader(MessageConst.PROPERTY_DELAY_TIME_LEVEL, DELAY_10S.getCode())
.build();
boolean sendResult = streamBridge.send(topic, message);

@dyrnq
Copy link

dyrnq commented Oct 31, 2024

@yanglei1980 thanks very much for your support.

@dyrnq
Copy link

dyrnq commented Nov 1, 2024

@yanglei1980 不过,比较奇怪啊,PROPERTY_DELAY_TIME_LEVEL还是老的 level 方式的头key啊,看名字是带_LEVEL的啊,而不是 TIMER_DELAY_SEC 自定义传的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants