Hook to trigger when a field collection item is being deleted I have create a module and I am using the following hook implementation.

The code works on success, but how do I prevent or stop further processing when I get failed as status?

mymodulename_field_collection_item_delete($field_collection_item) {
   $itemID = entity_id('field_collection_item', $field_collection_item);
   $fc = entity_load_single('field_collection_item', $itemID );
   $pid = $fc-&gt;field_product_guid['und'][0]['value'];
   $responseAPI = json_decode(deleteProductRequestAPI($pid,"DELETE"), true);
   if($responseAPI['status']=='success'){
     drupal_set_message(t('Is successfully deleted.'));
   }else{
     drupal_set_message(t('Failed to deleted.'));
   }
   die;
}
// here curl request sending 
functin deleteProductRequestAPI($pid,$method){
  // here i have written code for send request and will
  // get response in status as "success" or "failed".
}


The field Collection name is Products and the content type is Brands.
What you should do instead of an API call on delete is create a job with the QueueAPI in Drupal to create a job for processing later. In that job, pull the ID from the record (stored in the job) and do the API call. If the status failed, requeue the job. 

I can’t write all the code out for you but there are plenty of QueueAPI examples for D7 out there.

https://api.drupal.org/api/drupal/modules%21system%21system.queue.inc/group/queue/7.x

and

https://rbayliss.com/blog/drupal-queue-api/

Are great starting points.

You could then create a custom Drush command that processes  these jobs as fast as you desire. Note the section in rovs post that deals with “failed” states of a job and not removing it from the queue. That is key.

This will let Drupal function normally and defer errors in the remote system to you to work through.