wz2cool edited a comment on issue #88:
URL: https://github.com/apache/rocketmq-spring/issues/88#issuecomment-740458757
Currently, I found a workaround to get batch messages. But we still perfer
batch listener
```@RocketMQMessageListener(topic = "demo_product", consumerGroup =
"demo_batch_product_consumerGroup", consumeMode = ConsumeMode.ORDERLY)
public class ProductBatchConsumer implements RocketMQListener<String>,
RocketMQPushConsumerLifecycleListener {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public void onMessage(String message) {
// do noting, have to implement RocketMQListener or throw error
}
private AtomicInteger atomicInteger = new AtomicInteger();
@Override
public void prepareStart(DefaultMQPushConsumer consumer) {
consumer.setPullInterval(1000);
consumer.setConsumeThreadMin(1);
consumer.setConsumeThreadMax(1);
consumer.setConsumeMessageBatchMaxSize(1000);
consumer.setPullBatchSize(100);
consumer.registerMessageListener((MessageListenerConcurrently)
(msgs, context) -> {
System.out.println("batchSize: " + msgs.size());
int result = atomicInteger.addAndGet(msgs.size());
System.out.println("totalSize: " + result);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
});
}
}```
--
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]