[SR-Users] Dispatcher / ds_select_routes

Peter Gradwell peter at gradwell.com
Fri Sep 4 23:53:15 CEST 2020


Hello

I'm doing a project where I need to route using dispatcher across multiple groups. i.e. when the customer makes a call, the "core" server makes a request to cgrates to get back a list of carriers that support that, and then want to work through them in order of preference.

e.g. the string we get back from cgrates via evapi might be "2,1,3". i.e. try all Group 2 destinations, then group 1, then group 3.

Each of these is then a dispatcher group (with multiple dispatcher routes in each group).

When the call then gets to the "Group 2" server that in turn is also using dispatcher to handle multiple destinations, and if all of those destinations fail, it returns a 503 to the "core", which is then meant to try "Group 1", and so on.

The documentation on this is a bit sparse, but what I think I am meant to do (at the core level) is use ds_select_routes to load up the list of groups (https://kamailio.org/docs/modules/5.3.x/modules/dispatcher.html#dispatcher.f.ds_select_routes)

if(ds_select_routes("2=4;1=4;3=4", "d", "0"))
{
    t_on_failure("REROUTE");
    t_relay();
    exit;
}

and then in my failure_route, if the error code is 503 I call ds_next_domain, e.g.

failure_route[REROUTE] {
    if(t_check_status("503")) {
        if(ds_next_domain()) {
            t_on_failure("REROUTE");
            t_relay();
            exit;
        }
    }
}

My problem is, that in applying theory to practice, I have ended up with a bunch of looping and it's not working right!

Does anyone have an example code for such a scenario?

many thanks
peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20200904/4d7f8ade/attachment.htm>


More information about the sr-users mailing list