We write a custom alfresco activiti Extention. That extension contains the 1 REST web service. When this service is called they run the ExecuatorService(Java Thread) and respond to the user that your task is registered and will complete in few mins.
ExecuatorService Responsibilities: 1) Call the web service of the third-party system. 2) Update the process instance variable base on the third-party service response.
Now here we need the History Service Object, or how we update the process instance variable here. Actually, I write only 1 third-party system web service here but in reality it is 5 to 6 web services.