Implementing TM Forum Open APIs with MongoDB
How MongoDB speeds up development of new TM Forum services
In the evolving and increasingly complex telecommunications industry, providers are turning to open digital architectures to enable interoperability and manage new digital offerings.
TM Forum (TMF), an alliance of more than 850 companies, accelerates digital innovation through its TMF Open APIs, which provide a standard interface for the exchange of different telco data models. The use of TMF Open APIs ranges from providers of off-the-shelf software to proprietary developments of the largest telecommunications providers.
In working with many of the world’s largest communication service providers (CSPs) and the related software provider ecosystem, MongoDB has seen a significant number of organizations leveraging these emerging standards.
Through exposing common interfaces CSPs are able to adopt a modular architecture made up of best-of-breed components (either internally or externally developed) while minimizing the time, effort, and cost required to integrate them.
How TM Forum Open APIs Accelerate Innovation
Microservices in days, not weeks or months
The MongoDB document model allows developers to work with data in a natural way and store data as it is retrieved by the application. In the context of TMF Open APIs, this means that TMF resources of the API can be persisted 1:1 in the database without the need for additional mappings.
This is highlighted in the example below, which demonstrates how a portion of the TMF666 (Account Management) resource model can be simply and intuitively implemented as MongoDB documents as opposed to traditional relational structures.
When new versions of the specifications are released, or requirements demand that the data model be extended with custom defined data, the new attributes can be implemented in the application without having to spend time and effort changing database tables and constraints.
This flexibility allows CSPs to achieve the agility promise of TMF Open APIs in practice. Development teams can rapidly develop TMF-compliant microservices because there is no need to model TMF entity models in your relational database.
In partnership with full-stack digital BSS Finnish provider Tecnotree, MongoDB is helping build broader access for telecommunications development teams tasked with launching new microservices.
Tecnotree recently earned Platinum Badge for Open APIs from TM Forum and were among the first in the telecom industry to adopt, mature and stabilize open-source principles for Digital Business Support System (BSS).
Query data flexibly using TM Forum specifications
With this flexibility comes the ability to query data flexibly in order to support a variety of defined access patterns. This is demonstrated by the FinancialAccount resource in the TM666 specification (account management API).
The GET operation contains a parameter to specify which fields should be returned (a projection) and iterate through the result set by 'offset' and 'limit’ parameters. As the specification evolves, the MongoDB query language and rich indexing capabilities will allow for complex filter parameters to be easily supported.
The original GET operation referred to above can be implemented using MongoDB’s aggregation framework with the following query:
Adding additional filtering is as simple as including an additional $match stage as the first stage in the pipeline (with appropriate index support).
These aggregation queries can easily be represented in an idiomatic way using any of the supported drivers. The following Java example implementation shows how the above query can be written using the Java driver. No error-prone query string is needed nor an additional object-relational mapping layer to translate the result from MongoDB objects into Java objects.
Aside from some additional boilerplate code, this is the only code needed to get a basic working API. TMF provides the API as a Swagger specification, and this can be used to generate the resource and API classes automatically. These resource classes can be passed directly to the MongoDB driver, which will handle the translation into MongoDB data types.
The easiest way to access the Swagger file and get started is to download the specification from the TMF Open API resources page.
In the linked GitHub project, a Maven plugin is used to generate the code from the Swagger file, but this can also be manually done by using the Swagger Codegen CLI, depending on what fits better into the development workflow:
In most applications, more is needed than a functioning external API. Business processes, such as customer creation, may require that multiple operations on resources be treated as an atomic transaction. MongoDB has support for distributed transactions at global scale to fulfill this requirement at the database level.
Despite this, with the power of the document model, transactions are often not needed in many cases where a relational database would need them.
Take a look at the FinancialAccount again. Updating all related information in one atomic operation would require a transaction in relational databases, whereas it’s just one update operation of a document in MongoDB. This leads to an overall reduction in I/O and better application performance.
These advantages, combined with industry leading scale and resilience capabilities, drive CSPs to implement TMF APIs with MongoDB as the primary data source and indeed, many of the example implementations provided by TM Forum use MongoDB for data persistence.