07-13-2015 07:57 AM
Hi,
I'm currently developing a Java application, which observes serveral lines. My goal is to inform people, if a destination is reachable again, after they tried to call this destination prior to that.
So far so good, everything is working fine, except for one situation: if I'm calling a destination which is busy, I'm not able to get the CallingAddress / the CalledAddress, as both are null. Here's my code (I'm using a CallObserver to observe my own line and I'm evaluating the CallEvents. In this case it's the ConnCreated Event):
if (eventList[i] instanceof ConnCreatedEv) {
ConnCreatedEv ev = (ConnCreatedEv)eventList[i];
CiscoCall call = (CiscoCall)ev.getCall();
Address srcAddress = call.getCallingAddress();
Address destAddress = call.getCalledAddress();
if(srcAddress != null && destAddress != null) {
// Do something
}
}
After some debugging I found out that it's some kind of timing issue, as in debug mode and breakpoint set to the code block above the objects were never null. Currently my work around is surrounding srcAddress = call.getCallingAddress() and destAddress = call.getCalledAddress() with a while loop:
long startTime = System.currentTimeMillis();
long currentTime = System.currentTimeMillis();
Address srcAddress = call.getCallingAddress();
Address destAddress = call.getCalledAddress();
while(srcAddress == null || destAddress == null) {
currentTime = System.currentTimeMillis();
long difTime = currentTime - startTime;
try {
Thread.sleep(250);
} catch (Exception ex) {}
srcAddress = call.getCallingAddress();
destAddress = call.getCalledAddress();
if(difTime > 500) break;
}
if(srcAddress != null && destAddress != null) {
// Do something
}
It takes about 200-300ms to get the Address objects and my code is working fine again. But in my eyes it's pretty ugly and I'm not sure, if it can cause other issues with CUCM? Is there anything I can do, to prevent that issue? For the records: we're using CUCM 9.1.2.12900-11 and the JTAPI Specification-Version: 1.2 / CiscoJtapiClient Implementation-Version: 9.1(2.11017)-1
Thank you in advance!
Solved! Go to Solution.
07-13-2015 02:32 PM
Hi Rene,
By the time application receives the ConnCreatedEv calling address is set for the call. Called Address will be null at this time and will stay null till application receives ConnFailedEv.
I am not sure why application is seeing null for calling address. Are you using synchronous or Asynchronous observer? Are you seeing same behavior with JTRace sample app? Readme file in the JTAPI install location should have steps to run JTrace.
07-13-2015 02:32 PM
Hi Rene,
By the time application receives the ConnCreatedEv calling address is set for the call. Called Address will be null at this time and will stay null till application receives ConnFailedEv.
I am not sure why application is seeing null for calling address. Are you using synchronous or Asynchronous observer? Are you seeing same behavior with JTRace sample app? Readme file in the JTAPI install location should have steps to run JTrace.
07-15-2015 01:39 AM
Oh, sorry. You were right, only getCalledAddress returned null. Evaluating ConnFailedEV was the missing bit, thank you. My application is working fine now.
Just one question: are there any schematics, which describe the call flow regarding the Events? For example, if I call someone and he's busy, which Events occur etc.?
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide