RollBack2010 opened a new issue #12098:
URL: https://github.com/apache/pulsar/issues/12098
1. Download apache-pulsar-2.8.0-bin.tar.gz
2. Execute "pulsar-daemon start standalone" to start the service
3. Producer code:
```java
@GetMapping("/base/sendMsg")
public MessageId sendMsg(String msg) throws PulsarClientException {
PulsarClient pulsarFactory = pulsarConf.pulsarFactory();
Producer<byte[]> producer1 = pulsarFactory.newProducer()
.topic("my-topic")
.create();
MessageId send = producer1.newMessage().deliverAfter(3L,
TimeUnit.MINUTES).value("Hello Pulsar!".getBytes()).send();
return send;
}
```
4. Consumer Code
```java
@Bean
public void comsumerByListener() throws PulsarClientException {
MessageListener myMessageListener = (consumer, msg) -> {
try {
System.out.println("Message received: " + new
String(msg.getData()));
consumer.acknowledge(msg);
} catch (Exception e) {
consumer.negativeAcknowledge(msg);
}
};
PulsarClient pulsarFactory = pulsarConf.pulsarFactory();
pulsarFactory.newConsumer()
.topic("my-topic")
.subscriptionName("my-subscriptionByListener")
.messageListener(myMessageListener)
.subscribe();
}
```
Sending " base/sendmsg " request, the consumer immediately got the message,
" deliverafter ( 3l, timeunit.Minutes ) " three minutes of delay doesn't work,
why?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]