Best Practices for Subscriptions and Topics

Review best practices for subscriptions and topics used with Oracle Cloud Infrastructure Notifications.

Prevent Processing of Duplicate Items

An alarm, announcement subscription, event rule, connector, or contextual notification (alarm or event rule) can trigger a message . The Notifications service then sends the message to many types of subscriptions, including email, HTTPS endpoints, and functions.

Depending on your goals, you might want to prevent your system from processing duplicate messages from a given message trigger. This situation is especially relevant when sending messages to function subscriptions, which can result in double invocations. (For an example of a function subscription, see Scenario A: Automatically Resizing VMs.)

To prevent your system from processing duplicate messages, write code that de-duplicates received messages by using identifiers specific to the trigger:

  • For any message, consider using a custom de-dupe key entered in the body of the message.
  • For alarm-triggered messages, use a combination of dedupekey and timestampEpochMillis from the alarm message.
  • For event-triggered messages, use eventID from the event message.
  • For directly published messages, use X-OCI-NS-MessageId in the header (provided by Notifications). See Standard header metadata.

For handling duplicate requests sent to Oracle Cloud Infrastructure API endpoints, see Retry Token.

For related troubleshooting information, see Troubleshooting Notifications.