node-ts / bus

A typescript based enterprise service bus framework based on enterprise integration patterns
https://bus.node-ts.com/
MIT License
272 stars 25 forks source link

Rabbitmq transport polling #175

Closed blankley closed 2 years ago

blankley commented 2 years ago

We're using rabbitmq as a transport and seeing very high cpu usage. We can see over 12k Gets a second and it looks like we're polling rabbit with no timeout :

Screenshot from 2022-03-11 10-01-06

I added a:

await new Promise(r => setTimeout(r,1000))

to

https://github.com/node-ts/bus/blob/f3843df389351f66c3cc4ecaacd939bca70ec93c/packages/bus-rabbitmq/src/rabbitmq-transport.ts#L97

and see the expected 1 Get a second and normal CPU usage: Screenshot from 2022-03-11 13-07-35

Are we making a mistake in implementation? Missing something else?

adenhertog commented 2 years ago

thanks for finding that @blankley . I've pushed a change that internally uses callbacks rather than loops that should be much easier on your CPU.

This fix is available in the latest @node-ts/bus-core and @node-ts/bus-rabbitmq

blankley commented 2 years ago

Thanks! Great fix. Not to sound ungrateful, but would it be possible to back port this to the 0.6.x tree?