Skip to content

Commit

Permalink
Merge pull request #250 from Boris-Plato/example_fix
Browse files Browse the repository at this point in the history
Example fix
  • Loading branch information
Zerpet authored Feb 29, 2024
2 parents e61228a + 7ba88cc commit 7305875
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion _examples/pubsub/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ func publish(sessions chan chan session, messages <-chan message) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

pending := make(chan message, 1)

for session := range sessions {
var (
running bool
reading = messages
pending = make(chan message, 1)
confirm = make(chan amqp.Confirmation, 1)
)

Expand All @@ -117,6 +118,7 @@ func publish(sessions chan chan session, messages <-chan message) {
select {
case confirmed, ok := <-confirm:
if !ok {
pub.Close()
break Publish
}
if !confirmed.Ack {
Expand Down Expand Up @@ -190,6 +192,7 @@ func subscribe(sessions chan chan session, messages chan<- message) {
messages <- msg.Body
sub.Ack(msg.DeliveryTag, false)
}
sub.Close()
}
}

Expand Down

0 comments on commit 7305875

Please sign in to comment.