Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #1051 ] Close the channel before sending data if the consumer has been shutdown. #1052

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions consumer/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,6 @@ func (dc *defaultConsumer) shutdown() error {
k := key.(primitive.MessageQueue)
pq := value.(*processQueue)
pq.WithDropped(true)
// close msg channel using RWMutex to make sure no data was writing
pq.mutex.Lock()
close(pq.msgCh)
pq.mutex.Unlock()
mqs = append(mqs, &k)
return true
})
Expand Down
7 changes: 4 additions & 3 deletions consumer/process_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ func (pq *processQueue) putMessage(messages ...*primitive.MessageExt) {
select {
case <-pq.closeChan:
return
case pq.msgCh <- messages:
default:
pq.msgCh <- messages
}
}

Expand Down Expand Up @@ -293,8 +294,8 @@ func (pq *processQueue) getMessages() []*primitive.MessageExt {
select {
case <-pq.closeChan:
return nil
case mq := <-pq.msgCh:
return mq
default:
return <-pq.msgCh
}
}

Expand Down
1 change: 1 addition & 0 deletions consumer/push_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ func (pc *pushConsumer) pullMessage(request *PullRequest) {
NEXT:
select {
case <-pc.done:
close(pq.msgCh)
rlog.Info("push consumer close message handle.", map[string]interface{}{
rlog.LogKeyConsumerGroup: pc.consumerGroup,
})
Expand Down