Use filter_subject when calling extended consumer create API

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>
This commit is contained in:
Jean-Noël Moyne
2023-09-19 19:38:01 -07:00
committed by Neil Twigg
parent ad63d702c4
commit 40ce0a9d7e

View File

@@ -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)
}