we are building an Azure Function using node.js. This azure function is connecting to Solace using SolaceClient library and publishing a message into Solace topic. Currently, we are open and close the connection for a request. We want use the Connection Pooling concept in Solace Connectivity. so that, same connection can be used in different request.
Is there any way in can use the connection pooling? if yes, please provide us some documentation/github sample codebase.
if no, what is the best way to utilize the connectivity and get better performance or is it sufficient what ever we have implemented?
I am not sure exactly what type of Azure Function template you are using, but in general, objects defined outside of the function scope callback will persist between invocations of the Azure function calls. As long as the session instance is hoisted to the top level scope, it can be re-used multiple times.
Note, that there are no guarantees on lifecycle - keeping the session open forever will keep the function instance alive for some maximum timeout, but it is probably better to explicitly close the connection after a defined interval and reconnect if that specific container happens to be reused.
Here is a sample of an HTTP triggered Azure function that publishes a message to Solace, and will re-use the same connection if it is called again within 8 seconds: