Question

It's not clear how to use jain SIP stack in mutli-thread environment. I need to create multiple SIP sessions from different threads, e.g each client should be proceeded in its own transaction. Below is few options:

  • Use single SipProvider for receiving and sending SIP requests and do multiplexing on application side. SipProvider is not thread-safe, hence sending requests requires proper locking.
  • Create new SipProvider and new ListeningPoint for each client. This is how it works for me now. However, I don't really like it. And it's not clear, whther SipStack threadsafe or not
  • Create new instance of SipStack for every client
Was it helpful?

Solution

Its been a long time since I thought about JAIN-SIP (or even SIP for that matter or even Java) but here goes:

  1. Set the re-entrant listener flag when you create the stack. (look up the javadocs). Specify a thread pool size. When a sip request or response comes along, the stack may potentially create a new thread for you and invoke your listener.

  2. Your critical section is the SipListener implementation. You should not block for ever in it - otherwise new inbound requests and responses will not be routed to the sip listener for the transaction that is being processed at the time you blocked.

Hope that answers your question. Happy hacking.

Thats it.

OTHER TIPS

why don't you ue SIP Servlets, it lets you focus on your application logic and handles those details for you ? See http://code.google.com/p/sipservlets/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top