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
Aupdates the opportunity on AWS Partner Central. -
User
Bupdates 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.
-
When you receive
Opportunity Created,Opportunity Updated, orEngagement Invitation Acceptedevents, useGetOpportunityto fetch the latest data. -
When you receive
Engagement Invitation Rejectedevents, remove the corresponding opportunities.
-
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
LastModifiedDatefrom your stored data, ensuring it originates from AWS. -
Use the timestamp in the
AfterLastModifiedDatefilter 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 } ] }