__STARTDELIVERTIME property value to the property of the message that needs to be sent at a scheduled time (within 40 days). For delayed messages, you can first calculate the time point for scheduled sending and then send them as scheduled messages.System.currentTimeMillis() + delayTime, then send them as scheduled messages.Message msg = new Message("test-topic", ("message content").getBytes(StandardCharsets.UTF_8));// Set the message to be sent after 10 secondslong delayTime = System.currentTimeMillis() + 10000;// Set __STARTDELIVERTIME into the property of msg.msg.putUserProperty("__STARTDELIVERTIME", String.valueOf(delayTime));SendResult result = producer.send(msg);System.out.println("Send delay message: " + result);
Duration messageDelayTime = Duration.ofSeconds(10);final Message message = provider.newMessageBuilder()// Set topic for the current message.# LF#.setTopic(topic)// Message secondary classifier of message besides topic.# LF#.setTag(tag)// Key(s) of the message, another way to mark message besides message id.# LF#.setKeys("yourMessageKey-3ee439f945d7")// Set expected delivery timestamp of message..setDeliveryTimestamp(System.currentTimeMillis() + messageDelayTime.toMillis()).setBody(body).build();
Feedback