changyoutianxia commented on issue #6471:
URL: https://github.com/apache/rocketmq/issues/6471#issuecomment-1492958857

   SimpleConsumer simpleConsumer = provider.newSimpleConsumerBuilder()
                   .setClientConfiguration(configuration)
                   .setSubscriptionExpressions(subscriptionMap)
                   
.setConsumerGroup(mqConsumerConfig.getConsumerGroup()).build();
           while (true) {
               try {
                   List<MessageView> messageViews = simpleConsumer.receive(30, 
Duration.ofSeconds(10));
                   if (Objects.isNull(messageViews) || messageViews.isEmpty()) {
                       continue;
                   }
                   List<SendMessage> mqMessageList = 
messageViews.stream().map(v -> JSONUtils.toObject(new 
String(v.getBody().array(), StandardCharsets.UTF_8), 
SendMessage.class)).collect(Collectors.toList());
                   List<FullMessage> fullMessages = 
FullMessageConvert.INSTANCE.mqToPo(mqMessageList);
                   fullMessageService.saveBatch(fullMessages);
   
                   for (MessageView messageView : messageViews) {
                       simpleConsumer.ack(messageView);
                   }
               } catch (Exception e) {
                   log.error("consumer message fail,error:{}", e.getMessage());
               }
           }


-- 
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]

Reply via email to