Initializing and Monitoring APIs
This section describes how to initialize the Solace Messaging API for JavaScript and provides information for using logging and session statistics. For Solace JavaScript API examples, see Solace Developer Hub.
Initializing APIs
To work with the Solace JavaScript API, it must first be initialized.
Solace Messaging API for JavaScript and Node.js
Call solace.SolclientFactory.init(...) to initialize the Solace JavaScript API and Solace Node.js API. By default, when these APIs are initialized, they include the version 7 behavior profile for backwards compatibility. Behavior profiles allow old applications to remain compatible with old versions of the API, while allowing new applications to take advantage of updated recommended defaults. When writing a new application, Solace recommends using the newest available profile. For example, if version 10 is the newest profile, add the following to the entry point of your application to initialize the API with the version 10 profile and run it with the default property values that Solace recommends at the time of the version 10 release:
var factoryProps = new solace.SolclientFactoryProperties(); factoryProps.profile = solace.SolclientFactoryProfiles.version10; solace.SolclientFactory.init(factoryProps);
When modifying an existing application to use a new behavior profile, the differences between behavior profiles should be considered.
Cleanup
When the client application is finished using the Solace Messaging API, cleanup is not required for the Solace JavaScript API and Solace Node.js API.