Enabling Notifications
You can enable notifications at the creation of new API versions in order to notify existing subscribers (via email) that a new version of the API is available. If you want to send a different type of notification, you can extend the org.wso2.carbon.apimgt.impl.notification.Notifier abstract class on your own accordingly.
Follow the instructions below to enable notifications for new API versions:
Set the email server configurations in the
<API-M_HOME>/repository/conf/output-event-adapters.xmlfile under the<adapterConfig type="email">section.<adapterConfig type="email"> <!-- Comment mail.smtp.user and mail.smtp.password properties to support connecting SMTP servers which use trust based authentication rather username/password authentication --> <property key="mail.smtp.from">abcd@gmail.com</property> <property key="mail.smtp.user">abcd</property> <property key="mail.smtp.password">xxxx</property> <property key="mail.smtp.host">smtp.gmail.com</property> <property key="mail.smtp.port">587</property> <property key="mail.smtp.starttls.enable">true</property> <property key="mail.smtp.auth">true</property> <!-- Thread Pool Related Properties --> <property key="minThread">8</property> <property key="maxThread">100</property> <property key="keepAliveTimeInMillis">20000</property> <property key="jobQueueSize">10000</property> </adapterConfig>Log in to the Management Console and click Main > Resource > Browse.
Browse to the
/_system/config/apimgt/applicationdata/tenant-conf.jsonfile and click Edit as Text.Set the
NotificationsEnabledproperty to true as shown below:"NotificationsEnabled":"true", "Notifications":[{ "Type":"new_api_version", "Notifiers" :[{ "Class":"org.wso2.carbon.apimgt.impl.notification.NewAPIVersionEmailNotifier", "ClaimsRetrieverImplClass":"org.wso2.carbon.apimgt.impl.token.DefaultClaimsRetriever", "Title": "Version $2 of $1 Released", "Template": " <html> <body> <h3 style=\"color:Black;\">We’re happy to announce the arrival of the next major version $2 of $1 API which is now available in Our API Store.</h3><a href=\"https://localhost:9443/store\">Click here to Visit WSO2 API Store</a></body></html>" }] } ]A notification type can have multiple notifier classes that help send multiple notifications. In this case, notification sends via EMail but it could be SMS notification. Each notifier has a class attribute containing the full class path. The following properties should be set for the default
NewAPIVersionEmailNotifierclass:The following strings are replaced with API specific values in the
TitleandTemplateproperties.$1 - API name
$2 - New API version