You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "pzhx521 (via GitHub)" <gi...@apache.org> on 2023/05/05 10:28:58 UTC

[GitHub] [rocketmq-client-go] pzhx521 opened a new issue, #1044: PullConsumer Interface semantic issues

pzhx521 opened a new issue, #1044:
URL: https://github.com/apache/rocketmq-client-go/issues/1044

   I noticed that PullConsumer has the following interface: 
   ```golang
   Subscribe(topic string, selector consumer.MessageSelector) error
   Pull(ctx context.Context, numbers int) (*primitive.PullResult, error)
   ```
   When I subscribe to multiple topics using the same consumer. Calling the `pull` method, I cannot figure out which topic's data is being pulled.
   
   The business requirement is to use a pull mode consumer to subscribe to multiple topics.
   
   The pseudocode is as follows:
   
   ```goalng
   var nameSrv, _ = primitive.NewNamesrvAddr(nameServerAddr)
   pullConsumer, _ := mqcliv2.NewPullConsumer(
        consumer.WithGroupName("test"),
        consumer.WithNameServer(nameSrv),
        ...
   )
   var topics := queryFormDB(...)
   topics.range(func(item) {
       go func() {
       pullConsumer.Subscribe(topic,...)
       .....
   
       }
   })
   
   pullConsumer.Start()
   ....
   ```
   
   At this point, when I execute the `pullConsumer.Pull(...)` method, it is no longer semantically certain which topic's data is being pulled. (However, topic data can be indirectly obtained from the return value data), as is well known, the reason for this is that every call to Subscribe will reassign `pc. topic=topic`(https://github.com/apache/rocketmq-client-go/blob/8ea107c9b0ffb8aea61b9ea581899023a7b9b5a6/consumer/pull_consumer.go#LL132C12-L132C12). The calling order of Subscribe is unclear, and the final value of `pc.topic` cannot be determined.
   
   Therefore, I believe that the semantics of the PULL method are not very clear. It only means obtaining data from the latest pc.topic. thank you.
   We look forward to your reply.


-- 
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-unsubscribe@rocketmq.apache.org.apache.org

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


[GitHub] [rocketmq-client-go] francisoliverlee commented on issue #1044: PullConsumer Interface semantic issues

Posted by "francisoliverlee (via GitHub)" <gi...@apache.org>.
francisoliverlee commented on issue #1044:
URL: https://github.com/apache/rocketmq-client-go/issues/1044#issuecomment-1556434992

   you are right i think since message-queue is a param for java pull interface .
   https://github.com/apache/rocketmq/blob/develop/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java#L318-L375
   
   how do you like this ?
   ```golang
   Pull(ctx context.Context,queue *primitive.MessageQueue, offset int64, numbers int) (*primitive.PullResult, error)
   ```


-- 
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-unsubscribe@rocketmq.apache.org

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