Here is a sample TG config and explanation. 11 digits routed to SP1. International routed to SP2. 11 digits failover to SP2.
Phone Primary Line: Trunk Group 1
Phone DigitMap last rule is "(Mpli)". This translates to "(Mtg1)" because the primary line is TG1
Phone Outbound Route last rule is "{(Mpli):pli}". This translates to "{(Mtg1):tg1}".
You don't need any changes to the default DigitMap or Outbound Route.
ITSP A DigitMap: (1xxxxxxxxxx)
ITSP B DigitMap: (011xx.|1xxxxxxxxxx)
Voice Services -> Gateways and TGs -> Trunk Group 1
Trunk List: sp1,sp2
DigitMap: ((Msp1)|(Msp2))
Voice Services -> SP1 Service: X_NoRegNoCall: Checked
Service Providers ITSP A -> SIP -> TimerB: 10000
1st the Phone DigitMap validates the dialed number. If the number matches a pattern, the Outbound Route gets control.
If the number matches (Mtg1) in the Outbound Route, the call is routed to TG1. This is the only (Mtg1) function. It is not used to route the call to a trunk.
The Trunk List will route the call. Each trunk in the trunk list uses its corresponding DigitMap. This can't be changed. This is different than the normal outbound route process where you can compare the dialed number to virtually anything to route the call to a trunk.
The Trunk List is processed left to right.
An 11 digit number is compared to (Msp1). It will get a match and be routed to SP1. If the call fails, the number will be compared to (Msp2). It will get a match and be routed to SP2.
An international number is compared to (Msp1). It will not get a match and SP1 will be bypassed. It then will be compared to (Msp2). It will get a match and be routed to SP2.
There will be a 32 second wait before the call failovers. When X_NoRegNoCall is enabled the call will immediately failover when the trunk is not registered to the provider.
It is my understanding that the OBi might think the trunk is still registered when the trunk is down. There is a registration period and the OBi might not know the trunk is down until the registration period expires and the OBi tries to re-register. In this case the OBi will wait 32 seconds (defined in TimerB) before it failovers. I changed TimerB to 10 seconds. You can probably make it less, but if you make it too low you will get a false failover.
I defined (Mtg1) as ((Msp1)|(Msp2)). The (Msp1) is redundant and not needed. (Msp2) has all the needed patterns defined. I thought it might be confusing if I only used (Msp2). You can't use a rule like "xx." in (Msp1). If you do, all calls will be routed to SP1.