When the project starts, I use DefaultLitePullConsumerImpl as the consumer, and call the consumer's poll(long timeout) method to do some logic.
public class BizConsumer implements CommandLineRunner {
private DefaultLitePullConsumer consumer;
@Override
public void run(String... args) throws Exception {
consumer = new DefaultLitePullConsumer("group-name");
consumer.setNamesrvAddr("server address");
consumer.subscribe(...);
consumer.start();
SomeClass.executeAsync(consumer);
}
@PreDestroy
public void destroy {
if (consumer != null) {
consumer.shutdown();
}
}
}
public class SomeClass {
@Async
public void executeAsync(DefaultLitePullConsumer consumer) {
while (true) {
/**
* When Server shutdown, consumer.poll() will throw a Exception
*/
List<MessageExt> messages = consumer.poll(5 * 1000);
....
}
}
}
when the project is closed, I call the consumer's shutdown method, but the consumer's poll(long timeout ) is still running, then I got a Exception: java.lang.IllegalStateException: The consumer not running, please start it first.
I try to find a isClosed() or isRunning() method in DefaultLitePullConsumerImpl class, but I cannot find them.
What did you expect to see?
Is there a way to know that the consumer client has been closed ?
What did you see instead?
java.lang.IllegalStateException: The consumer not running, please start it first.
BUG REPORT
When the project starts, I use DefaultLitePullConsumerImpl as the consumer, and call the consumer's poll(long timeout) method to do some logic.
when the project is closed, I call the consumer's shutdown method, but the consumer's poll(long timeout ) is still running, then I got a Exception: java.lang.IllegalStateException: The consumer not running, please start it first.
I try to find a isClosed() or isRunning() method in DefaultLitePullConsumerImpl class, but I cannot find them.
Is there a way to know that the consumer client has been closed ?
java.lang.IllegalStateException: The consumer not running, please start it first.
jdk 8 Springboot 2.2.8 rocketmq-spring-boot-starter 2.1.0 CentOS 7