Amberflo managed app uses async events for all integration between Amberflo and Salesforce. It provides a two-way integration between the two systems.
- All communication between Amberflo and Salesforce is transparent and can be monitored in the Amberflo Async Events tab.
- An async event is created for every update of an Amberflo record. It makes it easier to monitor, search, and troubleshoot async events.
Each log entry records:
- Timestamp of the event
- Object type: Customer, Product Item, Promotion, etc.
- The outbound or inbound payload
- Request or response from the Amberflo API
- Action: Created, Updated, Deleted
- Status: Pending, Failed, Processed
- Number of attempts
The async event log has pre-defined filters.
An outbound async event is created when an Amberflo object is updated in Salesforce. This update is exported to Amberflo. These async event can be created as a result of triggers, or a manual update to the record in the UI, Flows, or Process Builder.
An inbound async event is created for each Amberflo object update sent from Amberflo. These events can be created as a result of webhooks or the sync job. See below.
- An async event is created for every update of one Amberflo record.
- Each async event is processed sequentially, one by one. It is designed to only chew up one Salesforce async thread and limit the scope of work being done to one record.
- This way the managed app does not create contention with other external integration systems using the async events in Salesforce.
- Why single record at a time and not a batch job? If there is an issue in processing multiple records in a single transaction, the whole transaction would fail and then we would have to repeat for all records in the batch.
- An async event is a record to be processed by an async job.
- Each async job is stored in the AsyncApexJob table, or the async job log.
- AFLO library uses a Queueable class which runs asynchronously to obtain the first record from the async events queue.
- One Queueable thread is created for each AFLO type: Customer, Promotion, ProductItem, etc.
- Once the Queueable is finished, it checks to see if there are more entries for its type (i.e. Customer, Promotion, etc.).
- If there are more entries to be processed, it reschedules itself (and adds a new entry in the job log). For example, if there are 100 async events, there will be 100 entries to the job log.
- The function of the sync job is to import data from Amberflo for a backfill or to sync record updates from Amberflo into Salesforce.
- The AFLO.DownloadScheduler() sync job imports data from Amberflo APIs and creates an async event for each imported record.
- This can be run manually by running the following script in the Salesforce developer console: (new AFLO.DownloadScheduler()).execute(null);
- Every time the job runs, it bring in all records from Amberflo to ensure that the two systems are consistent.
- The sync job is scheduled to run once a day by default. This can be disabled if you prefer to use webhooks. See Enabling webhooks for the Salesforce Managed App
- For each customer, bring in customer promotions. If there are 100 customers, there will be 200 async events.
- Product items
Updated 16 days ago