-
Notifications
You must be signed in to change notification settings - Fork 0
/
pull_message.go
42 lines (36 loc) · 1.06 KB
/
pull_message.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package rocketmq
type PullRequest struct {
consumerGroup string
messageQueue *MessageQueue
nextOffset int64
}
type PullMessageRequestHeader struct {
ConsumerGroup string `json:"consumerGroup"`
Topic string `json:"topic"`
QueueId int32 `json:"queueId"`
QueueOffset int64 `json:"queueOffset"`
MaxMsgNums int32 `json:"maxMsgNums"`
SysFlag int32 `json:"sysFlag"`
CommitOffset int64 `json:"commitOffset"`
SuspendTimeoutMillis int64 `json:"suspendTimeoutMillis"`
Subscription string `json:"subscription"`
SubVersion int64 `json:"subVersion"`
}
type Service interface {
pullMessage(pullRequest *PullRequest)
}
type PullMessageService struct {
pullRequestQueue chan *PullRequest
service Service
}
func NewPullMessageService() *PullMessageService {
return &PullMessageService{
pullRequestQueue: make(chan *PullRequest, 1024),
}
}
func (p *PullMessageService) start() {
for {
pullRequest := <-p.pullRequestQueue
p.service.pullMessage(pullRequest)
}
}