Q. 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
A. 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.
Final comment:
You were right, only getCalledAddress returned null. Evaluating ConnFailedEV was the missing bit,
My application is working fine now.
Comments
0 comments
Please sign in to leave a comment.