[ 
https://issues.apache.org/jira/browse/ROCKETMQ-237?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

JineLee updated ROCKETMQ-237:
-----------------------------
    Description: 
When I create a *New* ConsumeGroup and *setConsumeTimestamp* use the following 
code:

{code:java}        

this.defaultMQPushConsumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_TIMESTAMP);
           
this.defaultMQPushConsumer.setConsumeTimestamp(MQ_MSG_CONSUME_TIMESTAMP);
{code}

{code:java}
ms.mq.consume.timestamp=20170630120000
{code}

I notice that ReblancePushImpl 161# The field lastOffset always return 0:
Maybe as a new group ,should return -1?

{code:java}
case CONSUME_FROM_TIMESTAMP: {
                long lastOffset = offsetStore.readOffset(mq, 
ReadOffsetType.READ_FROM_STORE);
                if (lastOffset >= 0) {
                    result = lastOffset;
                } else if (-1 == lastOffset) {
                    if 
(mq.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
                        try {
                            result = 
this.mQClientFactory.getMQAdminImpl().maxOffset(mq);
                        } catch (MQClientException e) {
                            result = -1;
                        }
                    } else {
                        try {
                            long timestamp = 
UtilAll.parseDate(this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer().getConsumeTimestamp(),
                                UtilAll.YYYYMMDDHHMMSS).getTime();
                            result = 
this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);
                        } catch (MQClientException e) {
                            result = -1;
                        }
                    }
                } else {
                    result = -1;
                }
                break;
            }
{code}



  was:
When I create a *New* ConsumeGroup and *setConsumeTimestamp* use the following 
code:

{code:java}        
this.defaultMQPushConsumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_TIMESTAMP);
           
this.defaultMQPushConsumer.setConsumeTimestamp(MQ_MSG_CONSUME_TIMESTAMP);
{code}

{code:java}
ms.mq.consume.timestamp=20170630120000
{code}

I notice that ReblancePushImpl 161# The field lastOffset always return 0:
Maybe as a new group ,should return -1?

{code:java}
case CONSUME_FROM_TIMESTAMP: {
                long lastOffset = offsetStore.readOffset(mq, 
ReadOffsetType.READ_FROM_STORE);
                if (lastOffset >= 0) {
                    result = lastOffset;
                } else if (-1 == lastOffset) {
                    if 
(mq.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
                        try {
                            result = 
this.mQClientFactory.getMQAdminImpl().maxOffset(mq);
                        } catch (MQClientException e) {
                            result = -1;
                        }
                    } else {
                        try {
                            long timestamp = 
UtilAll.parseDate(this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer().getConsumeTimestamp(),
                                UtilAll.YYYYMMDDHHMMSS).getTime();
                            result = 
this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);
                        } catch (MQClientException e) {
                            result = -1;
                        }
                    }
                } else {
                    result = -1;
                }
                break;
            }
{code}




> ConsumeFromWhere.CONSUME_FROM_TIMESTAMP not work
> ------------------------------------------------
>
>                 Key: ROCKETMQ-237
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-237
>             Project: Apache RocketMQ
>          Issue Type: Bug
>          Components: rocketmq-client
>    Affects Versions: 4.0.0-incubating, 4.1.0-incubating
>            Reporter: JineLee
>            Assignee: Xiaorui Wang
>
> When I create a *New* ConsumeGroup and *setConsumeTimestamp* use the 
> following code:
> {code:java}        
> this.defaultMQPushConsumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_TIMESTAMP);
>            
> this.defaultMQPushConsumer.setConsumeTimestamp(MQ_MSG_CONSUME_TIMESTAMP);
> {code}
> {code:java}
> ms.mq.consume.timestamp=20170630120000
> {code}
> I notice that ReblancePushImpl 161# The field lastOffset always return 0:
> Maybe as a new group ,should return -1?
> {code:java}
> case CONSUME_FROM_TIMESTAMP: {
>                 long lastOffset = offsetStore.readOffset(mq, 
> ReadOffsetType.READ_FROM_STORE);
>                 if (lastOffset >= 0) {
>                     result = lastOffset;
>                 } else if (-1 == lastOffset) {
>                     if 
> (mq.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
>                         try {
>                             result = 
> this.mQClientFactory.getMQAdminImpl().maxOffset(mq);
>                         } catch (MQClientException e) {
>                             result = -1;
>                         }
>                     } else {
>                         try {
>                             long timestamp = 
> UtilAll.parseDate(this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer().getConsumeTimestamp(),
>                                 UtilAll.YYYYMMDDHHMMSS).getTime();
>                             result = 
> this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);
>                         } catch (MQClientException e) {
>                             result = -1;
>                         }
>                     }
>                 } else {
>                     result = -1;
>                 }
>                 break;
>             }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to