@@ -13,8 +13,8 @@ import (
1313 "sensorbucket.nl/sensorbucket/services/tracing/tracing"
1414)
1515
16- func StartMQ (svc * tracing.Service , conn * mq.AMQPConnection , queue , xchg , topic string ) {
17- pipelineMessages := mq .Consume (conn , queue , setupFunc (queue , xchg , topic ))
16+ func StartMQ (svc * tracing.Service , conn * mq.AMQPConnection , queue , xchg , topic string , prefetch int ) {
17+ pipelineMessages := mq .Consume (conn , queue , setupFunc (prefetch , queue , xchg , topic ))
1818
1919 log .Println ("Measurement MQ Transport running" )
2020 go processMessage (pipelineMessages , svc )
@@ -89,8 +89,11 @@ func processMessage(deliveries <-chan amqp091.Delivery, svc *tracing.Service) {
8989 }
9090}
9191
92- func setupFunc (queue , xchg , topic string ) mq.AMQPSetupFunc {
92+ func setupFunc (prefetch int , queue , xchg , topic string ) mq.AMQPSetupFunc {
9393 return func (c * amqp091.Channel ) error {
94+ if err := c .Qos (prefetch , 0 , false ); err != nil {
95+ return fmt .Errorf ("error setting Qos with prefetch on amqp: %w" , err )
96+ }
9497 _ , err := c .QueueDeclare (queue , true , false , false , false , nil )
9598 if err != nil {
9699 return fmt .Errorf ("error declaring amqp queue: %w" , err )
0 commit comments