Asterisk (at least when using PJSIP) and a given endpoint strips any URI details and will only use the endpoint and does not loop over all registered contacts.
From messge.c 'msg_send_exec'
Gets the outbound from res_pjsip_messaging.c 'get_outbound_endpoint'
/* attempt to extract the endpoint name */
if ((aor_uri = strchr(name, '/'))) {
/* format was 'endpoint/(aor_name | uri)' */
*aor_uri++ = '\0';
} else if ((aor_uri = strchr(name, '@'))) {
/* format was 'endpoint@domain' - discard the domain */
*aor_uri = '\0';
/*
* We may want to match without any user options getting
* in the way.
*/
AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(name);
}
/* at this point, if name is not empty then it
might be an endpoint, so try to retrieve it */
if (ast_strlen_zero(name)
|| !(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint",
name))) {
/* an endpoint was not found, so assume sending directly
to a uri and use the default outbound endpoint */
*uri = ast_strdup(to);
return ast_sip_default_outbound_endpoint();
}
From what I understant if you only use a URI (like pjsip:123.12.123.12:1234) it will just look for the default endpoint which will always be the same.