How to create a pool of connection in jsmpp?
Opened this issue · 8 comments
@pmoerenhout
Do you have an example on how to create a pool of connections using the library?
My USSD Gateway requires that I submit more than one connection if I want to connect to it with multiple instances of my USSD app. Do you have a way to achieve the above?
https://stackoverflow.com/questions/37113875/how-to-create-a-pool-of-connection-in-jsmpp
Do we have an answer to this question?
I have created a wrapper for that: https://github.com/pmoerenhout/jsmpp-pool using Apache commons Pooling.
This creates connections under the hood when needed.
@pmoerenhout thanks mate, let me take a look at it and will get back to you.
Hi @pmoerenhout , We have implemented & tested the pooled connections and here are our findings :
Testing with 2 maxTotal and 1 minIdle as pool settings :
At boot time the pool is created but with one instance as the USSD gateway does not allow two binds at a time . This means only one SMPPSession was created in the pool . On creating the second SMPPSession a connection reset is noticed .
This made us revert to using just 1 maxTotal and minIdle 1
With this setting we noticed that the SMPPSession is created and a successful bind is achieved with just one SMPPSession object in the pool . However when the SMPPSession is evicted from the pool due to the typical nature of the gateway to terminate smpp connections after a while , a new SMPPSession object is not created in the pool .
Do you have any thoughts on these concerns ?.
Thanks .
I'm working of extending the example of the pool to validate these scenario....
Set the minIdle to 1 or greater in the pool configuration to let the pool create a new session when no session are left. The timeBetweenEvictionRunsMillis in the pool determines after what time the session will be created. I updated to demo application to show this scenario, with the use of borrowObject. I also set the timeBetweenEvictionRunsMillis to 15000, so new sessions are created with 15 seconds, after the number of sessions is below the minIdle.
Thanks @pmoerenhout for the feedback . Will take this for a spin & provide feedback .
Hi @pmoerenhout . Thanks for the feedback i decided to use the semaphores with one session object per app instance . The only thing is to scale we will be having like 3 to 4 instances of the application each with one SMPPSession instance with an auto reconnect gateway implementation so the instance can reconnect to the same SMPPSession instance .
Dear @pmoerenhout do you plan to incorporate https://github.com/pmoerenhout/jsmpp-pool into the jsmpp codebase for the next release? How I can help?