0

Here I am using spring-cloud-starter-stream-rocketmq and spring-message to send message dn, e.g.

Message m = MessageBuilder.withPayload(obj).setHeader(RocketMQHeaders.TAGS, tag).build();
MessageChannel.output().send(m);

But I want to set the message expire time in the queue if that not be consumed.

I know the rocketmq could set the ttl, but I don't know whether that can be set for different message and how can be used in the code before?

Alvin
  • 133
  • 1
  • 1
  • 7

1 Answers1

1

I am afraid that you are wrong.

RocketMQ does not support ttl which means the message will NOT be deleted controlled by a client parameter, though the message will be indeed deleted after a period of time(for example 7 days).

So if you need to implement a ttl like consuming, you should do it in your consumer like:

  if (System.currentTimeMills()-msg.getStoreTimestamp > SOME_TIME) {
     //DO NOT CONSUME
  }
JaskeyLam
  • 15,405
  • 21
  • 114
  • 149