@@ -22,7 +22,6 @@ import (
2222 "time"
2323
2424 "github.com/apache/rocketmq-client-go/v2/consumer"
25- "github.com/apache/rocketmq-client-go/v2/errors"
2625 "github.com/apache/rocketmq-client-go/v2/internal"
2726 "github.com/apache/rocketmq-client-go/v2/primitive"
2827 "github.com/apache/rocketmq-client-go/v2/producer"
@@ -81,67 +80,37 @@ type PullConsumer interface {
8180 // Start the PullConsumer for consuming message
8281 Start () error
8382
84- // Shutdown the PullConsumer, all offset of MessageQueue will be commit to broker before process exit
85- Shutdown () error
86-
8783 // Subscribe a topic for consuming
8884 Subscribe (topic string , selector consumer.MessageSelector ) error
8985
9086 // Unsubscribe a topic
9187 Unsubscribe (topic string ) error
9288
93- // MessageQueues get MessageQueue list about for a given topic. This method will issue a remote call to the server
94- // if it does not already have any MessageQueue about the given topic.
95- MessageQueues (topic string ) []primitive.MessageQueue
96-
97- // Pull message for the topic specified. It is an error to not have subscribed to any topics before pull for message
98- //
99- // Specified numbers of messages is returned if message greater that numbers, and the offset will auto forward.
100- // It means that if you meeting messages consuming failed, you should process failed messages by yourself.
101- Pull (ctx context.Context , topic string , numbers int ) (* primitive.PullResult , error )
102-
103- // Pull message for the topic specified from a specified MessageQueue and offset. It is an error to not have
104- // subscribed to any topics before pull for message. the method will not affect the offset recorded
105- //
106- // Specified numbers of messages is returned.
107- PullFrom (ctx context.Context , mq primitive.MessageQueue , offset int64 , numbers int ) (* primitive.PullResult , error )
108-
109- // Lookup offset for the given message queue by timestamp. The returned offset for the message queue is the
110- // earliest offset whose timestamp is greater than or equal to the given timestamp in the corresponding message
111- // queue.
112- //
113- // Timestamp must be millisecond level, if you want to lookup the earliest offset of the mq, you could set the
114- // timestamp 0, and if you want to the latest offset the mq, you could set the timestamp math.MaxInt64.
115- Lookup (ctx context.Context , mq primitive.MessageQueue , timestamp int64 ) (int64 , error )
116-
117- // Commit the offset of specified mqs to broker, if auto-commit is disable, you must commit the offset manually.
118- Commit (ctx context.Context , mqs ... primitive.MessageQueue ) (int64 , error )
119-
120- // CommittedOffset return the offset of specified Message
121- CommittedOffset (mq primitive.MessageQueue ) (int64 , error )
122-
123- // Seek set offset of the mq, if you wanna re-consuming your message form one position, the method may help you.
124- // if you want re-consuming from one time, you cloud Lookup() then seek it.
125- Seek (mq primitive.MessageQueue , offset int64 ) error
126-
127- // Pause consuming for specified MessageQueues, after pause, client will not fetch any message from the specified
128- // message queues
129- //
130- // Note that this method does not affect message queue subscription. In particular, it does not cause a group
131- // rebalance.
132- //
133- // if a MessageQueue belong a topic that has not been subscribed, an error will be returned
134- //Pause(mqs ...primitive.MessageQueue) error
135-
136- // Resume specified message queues which have been paused with Pause, if a MessageQueue that not paused,
137- // it will be ignored. if not subscribed, an error will be returned
138- //Resume(mqs ...primitive.MessageQueue) error
89+ // Shutdown the PullConsumer, all offset of MessageQueue will be commit to broker before process exit
90+ Shutdown () error
91+
92+ // Poll messages with timeout.
93+ Poll (ctx context.Context , timeout time.Duration ) (* consumer.ConsumeRequest , error )
94+
95+ //ACK ACK
96+ ACK (ctx context.Context , cr * consumer.ConsumeRequest , consumeResult consumer.ConsumeResult )
97+
98+ // Pull message of topic, selector indicate which queue to pull.
99+ Pull (ctx context.Context , numbers int ) (* primitive.PullResult , error )
100+
101+ // PullFrom pull messages of queue from the offset to offset + numbers
102+ PullFrom (ctx context.Context , queue * primitive.MessageQueue , offset int64 , numbers int ) (* primitive.PullResult , error )
103+
104+ // UpdateOffset updateOffset update offset of queue in mem
105+ UpdateOffset (queue * primitive.MessageQueue , offset int64 ) error
106+
107+ // PersistOffset persist all offset in mem.
108+ PersistOffset (ctx context.Context , topic string ) error
109+
110+ // CurrentOffset return the current offset of queue in mem.
111+ CurrentOffset (queue * primitive.MessageQueue ) (int64 , error )
139112}
140113
141- // The PullConsumer has not implemented completely, if you want have an experience of PullConsumer, you could use
142- // consumer.NewPullConsumer(...), but it may changed in the future.
143- //
144- // The PullConsumer will be supported in next release
145114func NewPullConsumer (opts ... consumer.Option ) (PullConsumer , error ) {
146- return nil , errors . ErrPullConsumer
115+ return consumer . NewPullConsumer ( opts ... )
147116}
0 commit comments