Hi
Not the most efficient but possibly the simplest to explain is to use the
sqlops module to look for an override;
Something like;
# Load the module
loadmodule “sqlops.so”
# Where’s our DB?
modparam("sqlops","sqlcon”,” mydb
=>mysql://kamailio:kamailiorw@localhost/kamailio")
…
# Run query - returns 1 if results found
# watch out for SQL injection … check out transformation : {sql.val.str}
if (sql_xquery(“mydb", "select dispatcher_group from did_numbers where did =
$tU", "resultset”) == 1) {
xlog(“Routing to dispatcher group: $xavp(resultset=>dispatch_group)\n");
ds_select_dst($xavp(resultset=>dispatch_group), 4);
} else {
xlog(“Routing to default dispatcher\n");
ds_select_dst(1, 4);
}
sql_result_free("resultset”);
(code not checked in running environment so beware of typos :-)
If you’re working with SQL you can also add DB fields for source CLI, or
anything else you want to select on. If you’re going to be running a busy
server it’s worth investigating htables/redis or anything thats lighter weight
that SQL
Mark
> On 23 Jul 2020, at 16:17, Christoph Russow <[email protected]> wrote:
>
> Hi,
>
> sounds good how would somebody achieve that (which modules)?
>
> Best regards
> Christoph
>
> Am 23.07.20 um 15:52 schrieb Mark Boyce:
>> Hi
>> As well as alias_db a couple of variations I have used in the past are;
>> - keep a list of number destination overrides in a DB table and check there
>> before defaulting to dispatch. That way I can also route numbers to test/dev
>> servers etc based on additional bits like source cli
>> - keep a list of numbers vs dispatcher set groups. Keeping a dispatcher set
>> for "new" and one for “old” systems.
>> Mark
>>> On 23 Jul 2020, at 14:30, Christoph Russow <[email protected]> wrote:
>>>
>>> Hi,
>>>
>>> wow that was fast. thank you it seems to be exactly what i was looking for.
>>>
>>> it was just an idea of what might come so right now i won't implement it
>>> but maybe need to in the future.
>>>
>>> also what comes to mind it might help with the migration from the old
>>> systems. i could just dump all numbers in the lookup table and rout all
>>> calls to the old systems and then just remove number by number as we
>>> migrate them to the new systems.
>>>
>>> thank you again for the fast answer!
>>>
>>> best regards
>>> Christoph
>>>
>>> Am 23.07.20 um 15:08 schrieb Alex Balashov:
>>>> Hi,
>>>> If you are looking for a simple packaged solution that already
>>>> incorporates a database table, then the `alias_db` module is your best bet:
>>>> https://kamailio.org/docs/modules/5.3.x/modules/alias_db.html
>>>> The number can be translated to a SIP Request URI domain via
>>>> alias_db_lookup(), and that domain will of course be consumed when you
>>>> forward the request, absent other next-hop overrides.
>>>> If alias_db_lookup() returns false, then you can fall back to a dispatcher
>>>> election.
>>>> The major downside of this approach is that if your intent is to divert
>>>> only a small amount of numbers out of your load balancer, this, as all
>>>> other database-bound approaches, incurs an unnecessary database lookup for
>>>> every single call. However, this is not a significant factor in most
>>>> cases. It deserves some attention for very high CPS (Calls Per Second)
>>>> operators, though.
>>>> -- Alex
>>>> On 7/23/20 9:01 AM, Christoph Russow wrote:
>>>>> Hi all,
>>>>>
>>>>> im fairly new to Kamailio and currently setting up our new sip-server
>>>>> systems so, hello everyone!
>>>>>
>>>>> right now i have a Kamailio SBC which routes all calls using the
>>>>> dispatcher module to our internally setup application servers
>>>>> (freeswitch).
>>>>>
>>>>> i just got the idea that we might want specific routing based on
>>>>> destination phone number in addition to simple loadbalancing.
>>>>>
>>>>> can anyone point me in the right direction where i should look for
>>>>> something i can place before the dispatcher routing to route calls based
>>>>> on some entries in a database like destination number XYZ goes to server
>>>>> A, number ABC goes to server Z and so on.
>>>>>
>>>>> Or is there a way to select the dispatcher group id from the database
>>>>> based on destination number?
>>>>>
>>>>> best regards
>>>>> Christoph
>>>>>
>>>>> _______________________________________________
>>>>> Kamailio (SER) - Users Mailing List
>>>>> [email protected]
>>>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>
>>> _______________________________________________
>>> Kamailio (SER) - Users Mailing List
>>> [email protected]
>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> [email protected]
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> [email protected]
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Best regards
Mark
--
Mark Boyce
Dark Origins Ltd
e: [email protected]
t: 0345 0043 043
f: 0345 0043 044
_______________________________________________
Kamailio (SER) - Users Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users