Performing DNS lookups in Session Initiation Protocol (SIP) applications on Liberty
Use the Domain Resolver API in the application to perform Domain Name System (DNS) lookups of SIP URIs using the RFC 3263 protocol. We can perform synchronous lookups to avoid having to preserve state, which is required for an asynchronous callback. Alternatively, we can perform asynchronous lookups if we need a better performing interface.
In server.xml, install and configure the sipServlet-1.1 feature with a domainResolver element.
See Administer Session Initiation Protocol (SIP) on Liberty.
- Access the Domain Resolver API in the application.
- Get an attribute from the ServletContext method using com.ibm.websphere.sip.resolver as a key.
getServletContext().getAttribute("com.ibm.websphere.sip.resolver ")
- Get an attribute from the ServletContext method using com.ibm.websphere.sip.resolver as a key.
- Use resource injection.
@resource DomainResolver resolver
- Perform the URI lookup.
- To use the API synchronously, call the locate(SIPURI) method, which returns the result of the URI resolve request
response.
DomainResolver locate(SIPURI)
- To use the API synchronously, call the locate(SIPURI) method, which returns the result of the URI resolve request
response.
- To use the API asynchronously, call the locate(SIPURI, Listener) method, which
signals the listener after it finishes. When the result is cached, the listener is triggered on the same caller
thread.
DomainResolver locate(SIPURI, Listener)