Logo

Get Started

[TUTORIAL] Implement Consumption-Based Licenses image

[TUTORIAL] Implement Consumption-Based Licenses

10 MINUTES
Tutorials

Consumption-based licensing allows the software vendor to meter the usage of a given resource within their application. A resource can be the number of reports generated, API requests made, minutes of a service used, or the number of times an application is executed, for example. LicenseSpring supports the configuration of overages, as well as periodic allowance reset.

For this tutorial, we will be creating a chatbot that can increment, decrement and track consumptions. This guide will mention and provide code snippets from the code, as well as link the source code for the chatbot.

We made a video introducing the concept of consumption-based licensing, please enjoy.

 

Sections:

  • Activation Versus Consumption

  • Difference Between Consumption Licensing and Feature Consumption

  • Controlling the State of the Application with Total Consumptions and Max Consumptions, Overages, and Periodic Allowances

  • Considerations with Multiple Activations and Offline Usage

Activation Versus Consumption:

Activating doesn’t count as a consumption/using the license. If a user activates their license, they’ll still have 0 total consumptions. It is up to the developer to figure out what counts as a consumption and update accordingly using updateConsumption and syncConsumption. To be able to use consumptions on their license, a user must first activate their license.

Difference Between Consumption Licensing and Feature Consumption:

Unlike a consumption-based license, feature-based consumption allows additional flexibility for the software vendor, as they can then meter multiple components or modules of the same application differently. Features can also be set to expire, after which they are removed from the entitlement altogether.

Controlling the State of the Application with Total Consumptions and Max Consumptions, Overages, and Period Allowances:

The following function, updateConsumptions(), increases or decreases license consumptions by the value given in the first parameter. saveLicense is a boolean that controls whether the license should be saved to file or not.

void updateConsumption( int32_t value = 1, bool saveLicense = true )

This next function syncs the consumption license values with the server, so that the server is providing accurate consumption-based data. The parameter requestOverage allows users to request consumption overages.

void syncConsumption( int32_t requestOverage = -1 )

 

Published on: February 12, 2025
Last updated: February 12, 2025

Author

kyle
Kyle Brandon
DevOps Engineer - LicenseSpring Software
Kyle Brandon is a DevOps Engineer at LicenseSpring Software, based out of Vancouver, Canada. With over two years of experience at LicenseSpring, Kyle helps current and prospective customers with ensuring successful implementation of all LicenseSpring has to offer.

Share

Related Blog Posts
Using the Client SDK with LicenseSpring's Floating Server image

5 Minutes

Tutorials

Using the Client SDK with LicenseSpring's Floating Server

Read More

Software Product Versioning: LicenseSpring image

5 Minutes

Tutorials

Software Product Versioning: LicenseSpring

Read More