I need some help in designing the solution.
My requirement is I have around 50,000 contacts in my org. I need to send contacts(external id) to a Vendor-product, get the latest information(eg: email id, phone, address) and update the contact in our Salesforce.com CRM.
From Salesforce, take chunk of 10,000 contacts, pass the contact keys(external id) as HTTP REQ Parameter and make a HTTP call to Vendor-Product.
Vendor-product accepts this request and creates a batch Job.
Make another HTTP call to Vendor-Product to check the status of the Job.
Wait for the Vendor-Product job to complete.
When Vendor-Product job is complete, make another HTTP call to read the
Response (result of the job is in either Jason or CSV format based on my wish).
After reading the response (CSV or Jason format), update all 10,000 contacts (email, phonee, address) with latest information from the response.
Above process must run for 5 times to completer all 50,000 records.
Please provide some insight on how to implement it. Any code please.
Additional comments Please note that this process won't run daily, may be I would execute this process twice in a year to refresh all my contacts with fresh data(email, phone, address, etc)
- Mainjob –with multiple batch size of 1000 records.
Mainjob – use Batchable
- Inside Execute() method – Do following
- Make a HTTP request out to remote service
- Inside Finish method() – Do following
- Schedule new Job – JobChild for checking the status and request the result (may be after 10 minutes).
- I put a time delay between each batch, so that I can allow remote service to complete the previous request successfully?
- Can I pass a parameter( that is Remote service JOBID) to a new job –ChildJob ?
ChildJob use batchable
- Make HTTP request to remote service to check the status of the job – Pass JOBID
- If not complete, reschedule Childjob itself after a time gap.
- Make HTTP request to remote service, get the result.
- Read the response and update the contact records with response.
- Process the errors.
- ChildJob - I don't have any scope. Is that okay to have batachable job without scope ?