Multi-Threading Problem using JTAPI

Discuss any topic about <A href="http://www.brekeke.com/telephony/">Brekeke JTAPI SDK</A>.

Moderator: Brekeke Support Team

Locked
baltman195
Posts: 5
Joined: Sat Apr 07, 2007 10:19 am
Location: Charlotte NC

Multi-Threading Problem using JTAPI

Post by baltman195 »

1. Brekeke Product Name and version:

JTAPI1.0 and PBX 2.0.2.2

2. Java version:

1.6

3. OS type and the version:

Windows XP SP 2

4. UA (phone), gateway or other hardware/software involved:

5. Select your network pattern from http://www.brekeke-sip.com/bbs/network/ ... terns.html :

Pattern 8

6. Your problem:

I've modified the CalloutPlay demo to be a runnable thread. When I run one thread, it works fine but when I try to run two threads (to call out to two destinations simultaneously), the second thread get's the following error when I call mycall.connect:

[main] ERROR (BrCall.java:269) -
javax.telephony.InvalidStateException
at com.brekeke.jtapi.BrCall.connect(BrCall.java:165)
at GetPINThread.run(GetPIN.java:102)
at GetPIN.main(GetPIN.java:20)

Right before I call mycall.connect, I've inserted the following code:

System.out.println("Placing Call To " + DialNo +
" From Term " + origterm.getName() +
" From Addr " + origaddr.getName() +
" From Call " + mycall.toString());

The first thread prints:

Placing Call To 917044880282 From Term 101 From Addr 101 From Call com.brekeke.jtapi.callcontrol.BrCallControlCall@19113f8

and the second thread prints:

Placing Call To 919170410549 From Term 102 From Addr 102 From Call com.brekeke.jtapi.callcontrol.BrCallControlCall@1c208b0

I'm reasonably sure I'm not sharing variables between the class instances - I've changed the static's to private's.

The first call still works...

Is there a problem using the API multi-threaded, or am I doing something wrong ?

Thanks,

Bob A.
Andrea
Posts: 36
Joined: Wed Apr 04, 2007 11:41 am

Post by Andrea »

Hi
I tried the same thing (call out to two destinations simultaneously) and it worked fine.

You get "javax.telephony.InvalidStateException ".
You may find the reason of the exception by catching it.
Check if the provider you used for 2nd call is the same as the first call.

Good luck,
Andrea
baltman195
Posts: 5
Joined: Sat Apr 07, 2007 10:19 am
Location: Charlotte NC

Post by baltman195 »

Hi Andrea,

I was using the same provider and that was the problem.

I've since decided to go with one thread (and provider) and serialize the calls.

Thanks for the help,

Bob A.
Locked