All Products
Search
Document Center

Object Storage Service:Use MNS to send notifications of OSS events

Last Updated:Mar 20, 2026

Configure event notification rules in Object Storage Service (OSS) to monitor objects in your buckets. When a specified event occurs — such as an object being uploaded, deleted, or replicated — OSS sends a notification to a Simple Message Queue (SMQ, formerly MNS) queue.

This tutorial walks you through an end-to-end setup:

  1. Create two SMQ queues — one per region.

  2. Configure a cross-region replication (CRR) rule on the source bucket.

  3. Set up event notification rules on both buckets.

  4. Subscribe to the auto-created topics and receive notifications.

Prerequisites

Before you begin, ensure that you have:

  • Two OSS buckets in different regions: srcbucket in China (Hangzhou) and destbucket in UK (London)

  • Access to the SMQ console and the OSS console

  • A RAM role with permissions for CRR

Example scenario

Your company uses srcbucket in China (Hangzhou) to store logs and customer images in two directories:

srcbucket
└── log/
   ├── date1.txt
   ├── date2.txt
   ├── date3.txt
   └── ...
└── destdir/
   ├── photo1.jpg
   ├── photo2.jpg
   └── ...

All changes to objects in log/ and destdir/ — uploads, deletions, and modifications — must be replicated to destbucket in UK (London), and all employees must be notified when those changes occur.

To meet this requirement, configure a CRR rule on srcbucket and event notification rules on both srcbucket and destbucket.

Step 1: Create SMQ queues

Create one queue per region to receive event notifications from each bucket.

  1. Log on to the SMQ console.

  2. In the left-side navigation pane, choose Queue Model > Queues.

  3. In the top navigation bar, select the China (Hangzhou) region.

  4. On the Queues page, click Create Queue. Set the queue name to myqueue1 and keep the default settings for other parameters.

  5. Click OK.

  6. Switch to the UK (London) region in the top navigation bar and repeat the preceding steps to create a queue named myqueue2. myqueue2 receives notifications for events on destbucket.

Step 2: Configure a CRR rule for srcbucket

  1. Log on to the OSS console.

  2. In the left-side navigation pane, click Buckets. On the page that appears, click srcbucket.

  3. In the left-side navigation tree, choose Data Management > CRR.

  4. On the CRR tab, click CRR.

  5. In the CRR panel, configure the following parameters and click OK.

ParameterValueDescription
Destination bucketSelect UK (London), then select destbucketThe target bucket that receives replicated objects
Objects to replicateSelect Objects with Specified Prefix, then add prefixes destdir/ and log/Limits replication to only the two directories. If left blank, all objects in the bucket are replicated
Replication policySelect Add/Delete/ChangeReplicates object additions, deletions, and modifications
Replicate historical dataSelect YesReplicates existing objects in addition to future changes
RAM role nameSelect a role for CRRGrants OSS permission to write objects to destbucket. If no suitable role exists, create one in the RAM console first

Step 3: Configure event notification rules for srcbucket and destbucket

Important

The CRR rule configured in Step 2 replicates historical data to destbucket. If the bucket contains a large amount of data, this triggers a high volume of notifications during the initial sync. Wait until historical data replication completes before setting up event notification rules.

For each bucket, configure a separate notification rule:

  1. Log on to the OSS console.

  2. In the left-side navigation pane, click Buckets. Select srcbucket.

  3. In the left-side navigation tree, choose Data Processing > Event Notification.

  4. On the Event Notification page, click Create Rule.

  5. In the Create Rule panel, configure the parameters for srcbucket according to the following table and click OK.

Parametersrcbucketdestbucket
Rule namenotification1notification2
Event typePutObject, CopyObject, DeleteObject, DeleteObjectsObjectReplication:ObjectCreated, ObjectReplication:ObjectRemoved, ObjectReplication:ObjectModified
Resource descriptionSelect Prefix and Suffix, then add prefixes log/ and destdir/Select Prefix and Suffix, then add prefixes log/ and destdir/
EndpointSelect Queue, then enter myqueue1Select Queue, then enter myqueue2
  1. Repeat steps 2–5 for destbucket. Use the destbucket column values from the table above.

Note

New event notification rules take about 10 minutes to take effect.

Step 4: Subscribe to topics and receive notifications

When an event matching rule is triggered, SMQ automatically creates a topic. The topic name follows the format mns-en-topics-[Product]-[RuleName]-[Timestamp] — for example, mns-en-topics-oss-notification1-1700098799.

Subscribe to each topic to start receiving notifications.

Subscribe to the topic for srcbucket

  1. Log on to the SMQ console.

  2. In the left-side navigation pane, click Topics.

  3. In the top navigation bar, select the China (Hangzhou) region.

  4. Locate the auto-created topic and click View Subscriptions in the Actions column.

  5. In the panel that appears, click Subscriptions. On the page that appears, click Create Subscription.

  6. In the Create Subscription panel, configure the following parameters and click OK:

    • Name: mysubscription1

    • Push type: Queue

    • Receiver endpoint: myqueue1

    Keep the default settings for other parameters.

Subscribe to the topic for destbucket

Switch to the UK (London) region and repeat the preceding steps to create mysubscription2. Set Push type to Queue and Receiver endpoint to myqueue2.

Receive notifications

  1. In the left-side navigation pane, click Queues.

  2. Locate myqueue1 and choose More > Send Messages in the Actions column.

  3. In the Receive Message section, click Receive Message. You now receive notifications when objects in the log/ and destdir/ directories of srcbucket are created, modified, or deleted.

  4. Repeat the preceding steps for myqueue2 to receive notifications for replication events on destbucket.

Clean up

If you no longer need event notifications, delete the notification rules.

Important

Deleting an event notification rule does not delete the auto-created topic. To avoid unnecessary charges, delete unused topics from the SMQ console.