Best practices
Reacting to events
When handling events from AWS Partner Central API, ensure that your processing logic is idempotent to handle duplicate events. Instead of making immediate GetOpportunity calls for each event, consider batching or selectively fetching details based on your application's needs. For uninterrupted operations, beware of Quotas.
Implementing optimistic
locking
Optimistic locking prevents unintended data overrides during concurrent updates. Here's a typical scenario:
-
Partner retrieves an opportunity from their CRM system.
-
User
A
updates the opportunity on AWS Partner Central. -
User
B
updates the same opportunity at the same time through the CRM integration. -
If the data changes, the CRM system attempts to upload the data but returns a
ConflictException
. -
User reviews the error and manually resolves conflicting data.
To avoid this scenario, all UpdateOpportunity requests must include the LastModifiedDate
parameter, which you can obtain from previous CreateOpportunity, UpdateOpportunity, and GetOpportunity actions. The update succeeds only if
LastModifiedDate
matches our system. If it doesn't, you must fetch the
latest LastModifiedDate
using GetOpportunity and reattempt the update.
Synchronizing data between CRM and
AWS Partner Central
It is essential to keep your system synced with the latest data from Partner Central. The following are two strategies to ensure your system reflects the latest data:
Using events (recommended)
-
Load data using ListOpportunities.
-
Subscribe to opportunity events.
-
Respond to new opportunities or changes.
-
Fetch the latest data with GetOpportunity when you receive
Opportunity Created
,Opportunity Updated
, orOpportunity Accepted
events. -
Remove opportunities from your system upon receiving
Opportunity Rejected
events.
Using ListOpportunities polling
-
Load data using ListOpportunities.
-
Choose a polling frequency, ensuring it is not too frequent to avoid exhausting your daily read quota.
-
Identify the latest
LastModifiedDate
from your stored data, ensuring it originates from AWS. -
Use the timestamp in the
AfterLastModifiedDate
filter when calling ListOpportunities.{ "FilterList": [ { "Name": "AfterLastModifiedDate", "ValueList": [ "2023-05-01T20:37:46Z" ] // Replace with actual timestamp of your last synced data } ] }
-
AWS will return opportunities created or updated after the value indicated on the timestamp.
-
Iterate over all returned pages using
NextToken
, and update your system's data using GetOpportunity.{ "NextToken": "AAMA-EFRSN...PZa942D", "FilterList": [ { "Name": "AfterLastModifiedDate", "ValueList": [ "2023-05-01T20:37:46Z" ] // Replace with actual timestamp of your last synced data } ] }