I have an Apex class that is a controller for a Visualforce page. The VF page has a commandButton that calls a function in the controller that executes a batch process that processes some data, then executes another batch to process some more data before terminating. The chain continues until all the data is processed. I would use queueables, but I need to make a callout during each link of the chain, and queueables can't make a callout and a new queueable, only one or the other.
I want the VF page to show the progress of this process, but the controller doesn't know the ID of the current batch job, only the first one that it started. How can this be done? Do I have to create some kind of custom object to store state, and do a DML Update call at each link of the chain? That seems a little clunky, but the controller would be able to access that data with a DML call.