Koado opened a new pull request, #7082:
URL: https://github.com/apache/rocketmq/pull/7082

   <!-- Please make sure the target branch is right. In most case, the target 
branch should be `develop`. -->
   
   ### Which Issue(s) This PR Fixes
   
   <!-- Please ensure that the related issue has already been created, and 
[link this pull request to that issue using 
keywords](<https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword>)
 to ensure automatic closure. -->
   
   [Feature] Allow a BoundaryType to be specified when retrieving offset based 
on the timestamp #7074
   
   ### Brief Description
   
   <!-- Write a brief description for your pull request to help the maintainer 
understand the reasons behind your changes. -->
   Add two interfaces to the DefaultMQAdminExt class for the reason that 
messages will miss if there are multiple messages with the same 
storeTime(endTime) when retrieving messages over a period of time.
   1. searchLowerBoundaryOffset
   2. searchUpperBoundaryOffset
   
   ### How Did You Test This Change?
   
   <!-- In order to ensure the code quality of Apache RocketMQ, we expect every 
pull request to have undergone thorough testing. -->
   I wrote a test case to determine whether the maximum offset of the queue is 
equal to searchUpperBoundaryOffset(queue's  maxTimestamp),  and the minimum 
offset of the queue is equal to searchLowerBoundaryOffset(queue's  
minTimestamp). The codes are below:
   ```java
   String namesrvAddr = "127.0.0.1:9876";
           String topic = "test-topic";
   
           DefaultMQAdminExt mqAdminExt = new DefaultMQAdminExt();
           mqAdminExt.setInstanceName(UUID.randomUUID().toString());
           mqAdminExt.setNamesrvAddr(namesrvAddr);
   
           mqAdminExt.start();
           List<QueueTimeSpan> timeSpanList = 
mqAdminExt.queryConsumeTimeSpan(topic, null);
           if (timeSpanList != null && timeSpanList.size() > 0) {
               for (QueueTimeSpan timeSpan: timeSpanList) {
                   MessageQueue mq = timeSpan.getMessageQueue();
                   long maxOffset = mqAdminExt.maxOffset(mq);
                   long minOffset = mqAdminExt.minOffset(mq);
                   // if there is at least one message in queue, the maxOffset 
returns the queue's latest offset + 1
                   assertThat((maxOffset == 0 ? 0 : maxOffset - 1) == 
mqAdminExt.searchUpperBoundaryOffset(mq, timeSpan.getMaxTimeStamp())).isTrue();
                   assertThat(minOffset == 
mqAdminExt.searchLowerBoundaryOffset(mq, timeSpan.getMinTimeStamp())).isTrue();
               }
           }
   ```
   


-- 
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: commits-unsubscr...@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to