Skip to content

Commit

Permalink
Changing to workQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
qjoly committed Aug 26, 2024
1 parent 575b549 commit 800499d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions coffee-maker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ func main() {
defer cancel()

cfgStream := jetstream.StreamConfig{
Replicas: 3,
Name: streamName,
Subjects: []string{subjects},
Storage: jetstream.FileStorage,
Retention: jetstream.InterestPolicy,
AllowDirect: true,
Replicas: 3,
Name: streamName,
Subjects: []string{subjects},
Storage: jetstream.FileStorage,
Retention: jetstream.WorkQueuePolicy,
}

_, err = js.CreateOrUpdateStream(ctx, cfgStream)
Expand All @@ -63,9 +62,9 @@ func main() {
}

cc, err := cons.Consume(func(msg jetstream.Msg) {
fmt.Printf("New message from %s : %s - ", msg.Subject(), string(msg.Data()))
fmt.Printf("New message from %s : %s ", msg.Subject(), string(msg.Data()))
msg.InProgress()
time.Sleep(500 * time.Millisecond)
time.Sleep(10 * time.Millisecond)
msg.Ack()
fmt.Printf("\n")
})
Expand Down

0 comments on commit 800499d

Please sign in to comment.