Introduction to utilizing consumption-based licenses within the C++ SDK.
Handling product versioning at the license level
Product versioning allows vendors to release new versions of their licensed products and allows for more customization. This article will inform readers about defining and retrieving application versions, conditionally checking for updates using maintenance windows, verifying product versions on license check, and more.
- Define and Retrieve Versions of an App on/after Installation
- Conditionally Checking for Updates Using the Maintenance Window
- Verify Product Version on License Check
- Intermediate Updates, Channels, Minimum Required Version to Update, Maintenance Window, etc.
- Comparing Versions
Define and Retrieve Versions of an App on/after Installation:
Current app version can be accessed after initializing our Configuration object as shown below:
To set the application number, we adjust the fifth parameter of our Configuration constructor to reflect an appropriate version of the application being used:
To access a list of all available product versions, we use a method called getVersionList() that is called off the LicenseManager object. Acquiring a vector of strings containing all versions is done using the following lines:
Conditionally Checking for Updates Using the Maintenance Window:
The maintenance window feature is an effective way to check if there is an available update for a product. Since we have access to isMaintenancePeriodExpired(), which we can use as an indicator for when maintenance is finished. If this returns true, we receive the latest version of the product by running license->check() and can choose whether or not we update. Once we are informed of a maintenance period finishing, we can change this indicator to false so it does not consistently alert us that there is a new update.
Another way to check for new updates is to compare the version number of the installation file returned by license->check() to the current version being used. If they are not equal then there is an available update.
Verify Product Version on License Check:
To verify the most recently released product version on a license check, we will be creating an InstallationFile object to be equal to the return of license->check(). Since license->check() returns the most recent InstallationFile available for the license, we are then able to access the version by running
The product version would then be stored as a string in “version”, prepared to be verified against the current license version being used.
Intermediate Updates and Required Version:
An intermediate update is an update that requires a certain version of the predict to be currently installed. The required version can be checked by using:
RequiredVersion() is a getter method for the InstallationFile object that allows for access to the stored required version necessary to install the version.
An application channel is a logical communication link, used by applications to connect to a queue manager across a network. Channels are where the installation file is to be requested from, allowing the download of binaries for updates. For example, channels could be "prod", "dev", etc. An empty string means it uses the default channel. Channels are a string that is stored within the InstallationFile object that can be accessed by calling:
A Maintenance window is a period of time designated in advance, during which preventive maintenance that could disrupt service may be performed. This maintenance time is added to a license during creation, or can be added to an existing license within the edit license page. Maintenance period duration can be checked by using:
To check whether the license is currently undergoing maintenance, we use:
Or to check number of days remaining:
When retrieving a version, they are returned as strings. This can make it appear difficult to compare versions, to see whether a new version is older or newer, whether a build is on a certain patch, etc. In the Version.h file, you will find the VersionBase class. You can convert strings into a VersionBase class, which will allow you to compare these versions, as well as update them precisely. You can then convert these VersionBase classes back into strings.
There is a strategy used in the version.cpp sample code for automatically checking if the device is running on the newest version. Since we can use a license check to get the most recently released version, we can compare this string to our application stored within the configuration object we created. If they are not equal, we know we are on an outdated version.