Monetization Notifications not working

Symptom

Monetization Notifications are not working and hence emails are not being sent to the subscribed users.

Error Message

The emails about Monetization notification to the subscribed people will not be sent. No error messages will be observed.

About Monetization event notifications

Monetization supports event notifications that enable you to:

  1. Notify all developers about events such as new products, new versions of T&C's, or new rate plans.
  2. Notify specific developers about events such as a billing document being published or when a percentage of their target number of transactions is reached (if they purchased an adjustable notification rate plan).
  3. Notify an API provider about developer-related events, such as when a developer registers for an account or when a developer signs up for a rate plan.
  4. More details on this on what type of notifications are there and how one can set it up can be found here.

Prerequisites

Be sure the following prerequisites have been met:

  1. Rate Plan Acceptance

    For the following Monetization notifications, check if the developers have accepted the corresponding rate plan :

    1. New Rate Plan
    2. Revised Rate Plan
    3. Expired Rate Plan
    4. Renewed Rate Plan
    5. Rate Limit Exceeded
    6. Depleted Freemium Rate Plan

      If the developer has not accepted the rate plan, then these notifications will not trigger for that specific developer.

  2. Job Scheduler should be run for the specific Notification

    Monetization provides a job scheduler and a set of jobs that are pre-scheduled to run at pre-designated times. The job scheduler needs to be run for a specific notification. If it is not run, then the notifications will not be triggered.

    1. Use the instructions provided in the following doc to see if the scheduled job for a specific notification has run:

      https://docs.apigee.com/monetization/content/schedule-monetization-jobs

      Note: You can always change the schedule based on your use case.

    2. If the scheduled job for the specific notification has already run and you are still not getting the notifications, then proceed to Possible Causes section to troubleshoot this issue further.
    3. If not, then wait till the scheduled job for the specific notification runs.

Possible Causes

Some of the possible causes for this issue are:

Cause Description Troubleshooting Instructions Applicable For
SMTP Configuration Incorrect The SMTP configuration provided is not correct. Edge Private Cloud Users

Notification job schedule

The notification job hasn't started. Edge Public Cloud and Private Cloud Users

Cause 1: SMTP Configuration Incorrect

Diagnosis

  1. Check /opt/apigee/edge-mint-management-server/conf/apix-mint.properties file and verify if the following SMTP properties are set correctly.
    mint.notification.javaMail.properties={"mail.smtp.host": "smtp.gmail.com",
    "mail.smtp.port": "465", "mail.smtp.starttls.enable": "true", "mail.smtp.auth": "true", "mail.smtp.username": "blah@gmail.com", "mail.smtp.password": "blah" }
    
  2. Verify if the SMTP server and user settings are correct. If these settings are incorrect or not set, proceed to Step #3. If this is correct, proceed to Step #4.
  3. Update the SMTP server and user settings correctly by using the instructions in the following doc:

    https://docs.apigee.com/private-cloud/latest/configuring-edge-smtp-server

  4. Re-check again if the Monetization notifications are now working. If not, please proceed to Step 5.
  5. If the SMTP settings are correct, then run View notifications sent API call to see the status of the notification sent.
    1. This API returns a JSON with all the notification that have been fired and the status of each of those.
    2. A sample JSON is provided below :
      {
              "hasMoreItems" : false,
              "notifications" : [ {
              "fromAlias" : "No Reply",
              "fromEmail" : "****@apigee.com",
              "id" : "4e2d0d9a-69a4-4430-957d-02fa2a3cb581",
              "notificationType" : "EMAIL",
              "orgId" : "myorg",
              "rawMessage" : "...",
              "retryCount" : 0,
              "retryStatuses" : [ {
                   "responseCode" : 0,
                   "responseMessage" : "{\"Headers\":null,\"Content : \":null,\"StatusCode\":\"0\"}",
                   "retriedAt" : 1518605291092,
                   "retryAttempt" : 0
              } ],
              "source" : "MailTo: [****@blah.com], Org: [myorg], EventType: [UPDATE_DEVELOPER]",
              "status" : "FAILED",
              "subject" : "Notification of developer changing company details",
              "templateId" : "814315c8-d8ca-4b3e-90bb-a8366600e625",
              "templateName" : "DEFAULT_UPDATE_DEVELOPER_TEMPLATE",
              "templateParametersJSON" : "{\"developer.legalName\":\"\",\"developer.name\":\"John Smith\"}",
              "toAlias" : "***@blah.com",
              "toEmail" : "***@blah.com",
              "unsubscribeURL" : "..."
      }
      

      If you check the JSON, it shows the status as 'FAILED' for the above particular notification 'Update Developer'.

  6. This could possibly be caused because the SMTP server and port might not be reachable from the Management Server. Use the telnet command to check if you are able to connect to the specified SMTP server on the specified port.
    telnet <SMTP-server-IP-address> <SMTP-Port#>
    

    If you get the error "Connection timed out" or "Connection refused" for the telnet output, then proceed to Resolution.

Resolution

  1. Work with your network administrator and ensure the SMTP server is able to accept connections from other machines and also the specific port is open to outside world for communication.
  2. If the issue still persists, then proceed to the Must Gather Diagnostic Information with the

Cause 2: Notification Job Schedule

The notification job hasn't started.

Diagnosis

  1. Run the following API call to view all currently scheduled monetization jobs.

    https://docs.apigee.com/monetize/apis/get/triggers

  2. Check whether the notification condition is present and is enabled for the notification that is not working. If it is not present, proceed to Step #3 to create the notification condition and skip the rest of the steps.
    1. If its present, then check whether its enabled to true. If not, then run the Update a notification condition and action API to update the notification condition.

      OR

    2. Use the UI to update the notification condition using the process provided in the below doc:

      https://docs.apigee.com/monetization/content/set-up-notification-templates#eventsui

    3. Run the Create a notification condition and action API call to create the appropriate notification condition and the corresponding action.
      1. Once the notification condition is created, run the View all notification conditions and actions API call to verify if the notification condition has been created.
      2. You can also reprocess the notification using Reprocess a notification API.
    4. This step is only applicable for Private Cloud users. If the notification condition is present from step #1 and the notification emails are still not coming, then check the management server log /opt/apigee/var/log/edge-management-server/logs/system.log and see if the notification condition has been triggered.
      grep "Executing Mint Scheduler" /opt/apigee/var/log/edge-management-server/logs/system.log | grep  -o  "Executing Mint Scheduler : \[.*\]" | grep -v "for org : \[null\]" |sort | uniq -c
      
    5. If the notification condition is triggered, and you are still not getting the notifications, then proceed to Must Gather Diagnostic Information with information and output from above steps captured.

Resolution

  1. Reprocess the notification using the Reprocess a notification API

Must Gather Diagnostic Information

If the problem persists even after following the above instructions, please contact Apigee Support and provide the following diagnostic information.

Public and Private Cloud users should provide the below information:

  1. Organization Name
  2. Environment Name
  3. Monetization Notification condition that did not work
  4. Details about what sections in this Playbook has been tried and any other insights that will help us to fastrack resolution of this issue.

In addition to the above information Private Cloud users should also provide the following information:

  • Management Server log

    /opt/apigee/var/log/edge-management-server/logs/system.log