cancel
Showing results for 
Search instead for 
Did you mean: 

GetConnectionFromPool

Former Member
0 Kudos

From Documentation:

If there is no connection avaliable in the pool,

a newly constructed SAPConnection object will returned.

My question is, if the max number of connections (MaxCapacity) is reached, does GetConnectionFromPool wait some specified time before returning with a connection? Or failing becasue no connection became available?

thanks, Philip

Accepted Solutions (0)

Answers (1)

Answers (1)

reiner_hille-doering
Active Contributor
0 Kudos

MaxOpenConnections will force connection.Open to block. See other thread for details.

Former Member
0 Kudos

>> MaxOpenConnections will force connection.Open to block

Is there an easy way to determine if connection.Open will block before calling Open? It seams strange that Open will block rather than wait a specified amount of time to see of a connection becomes available. If I can determine if the max connections is reached before calling Open, I could code for this.

thanks, Philip

reiner_hille-doering
Active Contributor
0 Kudos

> Is there an easy way to determine if connection.Open

> will block before calling Open? It seams strange

> that Open will block rather than wait a specified

> amount of time to see of a connection becomes

> available. If I can determine if the max connections

> is reached before calling Open, I could code for

Why do you think it's strange that the function blocks? What behaviour would you want to achieve? Could you decribe the possible scenario?

The idea in the current implementation is to allow to "throttle" the ammount of connections that are created by SAP .NET Connector. If this ammount is reach, it seems natural that a possible user has to wait until the requested resource is available again.

Former Member
0 Kudos

Maybe this is a communication problem. I apologize.

When you said "Block" I assumed you meant "Block". Are you saying that "Block" means "Wait". If so that's great.

Basically, I want to set up a pool of 40 connections. If 40 connections are in use, then the next connection ideally would "Wait" for a connection and not be permanantly "Blocked".

If this is how this works, how long does it "Wait" for a connection to become available? Can the wait time be configured.

thanks in advance, Philip

reiner_hille-doering
Active Contributor
0 Kudos

This is exactly what will happen if you set MaxOpenConnections to 40. However, the 41th connection would wait forever, if there is no other thread is returning a connection to the Pool.

Former Member
0 Kudos

Can the wait time be configured?

reiner_hille-doering
Active Contributor
0 Kudos

As I wrote before: No.

Former Member
0 Kudos

Hi,

Just an idea Philip...

If you really want to control the time the connector tries to open a connection, I see 2 options for you:

- you can maintain a (global) count of the connections you opened from the pool (you will also need to keep track of those you close) and then make sure you don't call open if you passed the max available connections you defined (do you're own wait if the pool is empty).

- Open the connections in an async call

both a little tricky to do, but if you think you must have this feature.. that's what I can offer you. I would instead try to make sure I don't keep connections open for too long and that I have enough in the pool. anyway, good luck

Regards,

Ofer

reiner_hille-doering
Active Contributor
0 Kudos

> - you can maintain a (global) count of the

> connections you opened from the pool (you will also

> need to keep track of those you close)

This is exactly what happens internally in the Open call (and some other of cause). You can also just turn our "connections throtteling" feature off by setting MaxOpenConnections to 0 and implement your own strategy on your own by counting each Open and Dispose of your cnnections.

We could also think about implementing a timeout for the maximum waiting time. If the time is over we would throw an exeption, because connection could not be opened without violating the MaxOpenConnections rule.

We could perhaps implement this in a future patch version. We could do it if we there is a really good reason / business case for it.