huysentruitw/SapNwRfc

Pool connection blocked ?

Closed this issue · 3 comments

Hello,
i'm facing an issue that im not able to resolve by myself.

My code looks like something like that :

// EditContactFunction
_sapConnection.InvokeFunction<ContactCreateOutput>("ZSD_CUSTOMER_MAINTAIN_ALL", params)
var commitResult1 = _sapConnection.InvokeFunction<CommitTransactionResult>("BAPI_TRANSACTION_COMMIT", new { WAIT = "X" });
_sapConnection.InvokeFunction<AddressCreateOutput>("BAPI_ADDRESSCONTPART_CHANGE", params2)
var commitResult2 = _sapConnection.InvokeFunction<CommitTransactionResult>("BAPI_TRANSACTION_COMMIT", new { WAIT = "X" });

I dont understand why but :

  • the first invoke works every time
  • the second one works the first time i run it, but if i run the function multiple time the second invoke end up working intermittently

It looks like i have to wait X seconds between every run of the edit function if i want the second invoke to works

I tried to add

 _sapConnection.Dispose();

after every BAPI_TRANSACTION_COMMIT and the behaviour changed a little bit :
Both invoke worked fine but i can run my edit function only 5 time (which is my poolsize)
after that the invoke is blocked and never return

any idea ?

Hi Lucas,

can you be more specific what you mean by "first invoke" and "second invoke". Seems like you're talking about 2 invokes, while your example contains 4 invokes.

From where do you get the _sapConnection? If you dispose the _sapConnection, how do you recreate it for the BAPI_ADDRESSCONTPART_CHANGE call?

Hi !
Sorry i was talking about ZSD_CUSTOMER_MAINTAIN_ALL + COMMIT as first invoke "block" and BAPI_ADDRESSCONTPART_CHANGE + COMMIT as second one

this is how i get the sapConnection :

startup.cs
image
image

BapiService.cs
image

Mutation.cs
image

If you dispose the _sapConnection, how do you recreate it for the BAPI_ADDRESSCONTPART_CHANGE call?

Well i dont know 😁 thought it was going to acquire new connection from the pool automatically.
Anyway i only did it for testing i'm not supposed dispose after each call, right ?

i have tried to change the BAPI_ADDRESSCONTPART_CHANGE by another random BAPI and it works every time, so i guess the problem is coming when combining this two BAPI... maybe a lock issue ?
as i said adding dispose() after first commit resolve the problem but its opening new connections
image