Skip to content

Commit

Permalink
Use filter_subject when calling extended consumer create API
Browse files Browse the repository at this point in the history
The server consumer creation code is picky and does indeed not accept a request send to the ExT subject if that request specifies the subject filter in the array (even if there is only one entry in the array).

Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>
Signed-off-by: Neil Twigg <neil@nats.io>

Co-authored-by: Jean-Noël Moyne <jnmoyne@gmail.com>
Co-authored-by: Neil Twigg <neil@nats.io>
  • Loading branch information
jnmoyne and neilalexander committed Sep 20, 2023
1 parent ad63d70 commit 40ce0a9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/stream.go
Expand Up @@ -2895,7 +2895,11 @@ func (mset *stream) setSourceConsumer(iname string, seq uint64, startTime time.T
subject = fmt.Sprintf(JSApiConsumerCreateExT, si.name, req.Config.Name, req.Config.FilterSubject)
} else if len(req.Config.FilterSubjects) == 1 {
req.Config.Name = fmt.Sprintf("src-%s", createConsumerName())
subject = fmt.Sprintf(JSApiConsumerCreateExT, si.name, req.Config.Name, req.Config.FilterSubjects[0])
// It is necessary to switch to using FilterSubject here as the extended consumer
// create API checks for it, so as to not accidentally allow multiple filtered subjects.
req.Config.FilterSubject = req.Config.FilterSubjects[0]
req.Config.FilterSubjects = nil
subject = fmt.Sprintf(JSApiConsumerCreateExT, si.name, req.Config.Name, req.Config.FilterSubject)
} else {
subject = fmt.Sprintf(JSApiConsumerCreateT, si.name)
}
Expand Down

0 comments on commit 40ce0a9

Please sign in to comment.