I wrote an application which is sending Sip Invite Message to a destination. After some period (10 ms,100 ms,whatever) response message comes from destination. I'm doing some businnes in processResponse.
So this issues are asynchronous!!! By the way i'm using nist library for sip messaging.
Another project team requesting a library from me. They want to use my application by calling synchronously.
What is the simplest way to do this ?
How can i call my asynchronous task via synchronous method ?
alp carsikarsi wrote:Thanks jayesh. is this solution works on heavy simultaneus request load ?
Any solution that uses a synchronous call that waits on a background job to complete will have an inherent cost:- The thread that called your synchronous method will wait till the background process is complete. This means that if your app server spawns a thread for each request, there is one more thread for the OS to keep track off, or if the app serves uses a thread pool (as most app servers do), there is one less thread to service other requests. Either way, you will be bottlenecking. This may or may not be a big deal depending on the frequency of requests, and time taken to process each request.
Besides that, if you use the mechanism that I described, there will be an overhead while you continuously poll for completion. It depends on what the cost of each call is. I am not familiar with the library that you are using. If the mechanism that Stephen described is available, it should be less costly, since you will be spending more time in wait