Re: [Asterisk-java-users] PRI Hangup Cause
Brought to you by:
srt
From: Chetan M. <che...@pi...> - 2010-04-29 16:50:06
|
Hi Yves , Thanks for your response. Here the pseudo code of my application and dialplan. Paste-bin link http://pastebin.com/tAqEb5FF JAVA-CODE: import java.util.HashMap; import java.util.Map; import org.asteriskjava.manager.AbstractManagerEventListener; import org.asteriskjava.manager.ManagerConnection; import org.asteriskjava.manager.ManagerConnectionFactory; import org.asteriskjava.manager.action.OriginateAction; import org.asteriskjava.manager.event.CdrEvent; import org.asteriskjava.manager.event.HangupEvent; import org.asteriskjava.manager.event.OriginateResponseEvent; public class ContactDialer { private ManagerConnection pbx; private String context ="broadcast"; private int priority=1; private String extension="555"; private String channel= "zap/g1/"; public void connectToPBX(String host,String user, String secret,int port) throws Exception{ /*Create connection to Asterisk server and Register Event Listener*/ pbx= new ManagerConnectionFactory(host, port, user, secret). createManagerConnection(); pbx.login(); pbx.addEventListener(new DialerEventListener()); } public void dial(String number,String mssgFile,String actionID)throws Exception{ /*calls a number using any of channel in group g1 and transfer the call to extention 555 in dialplan*/ OriginateAction oAction= new OriginateAction(); oAction.setAsync(true); oAction.setChannel(channel +number); oAction.setContext(context); oAction.setPriority(priority); oAction.setActionId(actionID); //Actionid to identify a call oAction.setVariable("mssg", mssgFile); /*this variable will be used in dialplan to play the voice-message*/ pbx.sendAction(oAction); } public static void main(String[] args) throws Exception{ /*The number and message file name are retrieved from database*/ String number ="XXXXXXX"; //Number To be called String messageFile="message"; //File to be played ContactDialer cd=new ContactDialer(); cd.connectToPBX("localhost", "user", "secret",5038); cd.dial(number, messageFile, "action-id"); /*actionid to uniquely identify a call, generally a database key value*/ Thread.sleep(1000*60*2); //since it is pseudo code call a number and wait for response*/ } } class DialerEventListener extends AbstractManagerEventListener{ private Map callResponse= new HashMap(); @Override public void handleEvent(OriginateResponseEvent event){ /* get action id and associate it with uniqueid for further use*/ if(event.isSuccess()){ callResponse.put(event.getUniqueId(), event.getActionId()); } else{ //call failed, log its details to database } } @Override public void handleEvent(CdrEvent event){ /*get Actionid and log it to database*/ if(callResponse.containsKey(event.getUniqueId())){ /*we have a successful call */ } } @Override public void handleEvent(HangupEvent event){ /* this is problem area, how to associate hang-up cause with a call ? No uniqueID is generated in OriginateResponse for failed call. */ if(event.getCause() == 16){ /* call succeeded - log it to DB when we get the CDR*/ } } } DIALPLAN (dialplan really simple ;) ) [broadcast] exten => 555,1,Answer() exten => 555,n,Playback(${mssgFile}) exten => 555,n,waitExten(4) exten => 555,n,Hangup() Regards, -- -Chetan Meshram On Wed, 28 Apr 2010 16:48:50 +0200, Yves Arikoglu wrote: > Hi Chetan, > > of course there is... but as always... it depends... > first.... to be compatible with my recommendations, you should use the > most new version of asterisk-java. 0.3 is far old. > second, the way to get the events in the manner you need them may depend > on asterisk-version and your dialplan. > as you write, you´re using asterisk 1.4 (which should be ok), but i > don´t know how your dialplan looks like and how > you make the call... (originateaction in async way is not enough). so > please post your java code and the dialplan. > i need to know if your using local channels for example, if you´re > dialling to an s-extension and so on.... > > yves > > Chetan Meshram schrieb: >> Hi, >> >> I have been asked to design a system that would pick numbers from a >> contact database,call them and play a pre-recorded voice message. If a >> call >> fails for some reason it is retried after an interval of 20 min. The >> number >> is retried 2-3 times, depending on retry configuration, after the said >> interval. >> >> Now since the number of calls that we make is very large I want to >> make the retry mechanism more streamlined like not to retry numbers which >> are switched-off,absent-subscriber etc. >> >> I am using asterisk-java-0.3 and asterisk-1.4.28. To call a number I >> am >> using OriginateAction (asynchronously) and AbstractManagerEventListener >> to >> log responses. The "public void handleEvent(HangupEvent event)" method >> does >> tell you about the PRI hangup cause but there is no way to link it with >> an >> OriginateResponse for failed calls. The only hangup-cause I am getting >> is >> >> NOTDEFINED-0 >> NORMAL-1 >> BUSY-2 >> FAILURE-3 >> CONGESTION-4 >> UNALLOCATED-5 and >> Normal Clearing-16 (for successful calls). >> >> Is there any way to get the PRI hangup-cause associated with a >> call. >> >> > > > ------------------------------------------------------------------------------ > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users |