Database Roll Back in Flowable

i am having a Java Application, and whenever there is a process related flow then interacts with Flowable BPM by REST API Calls (for starting a process,assigning task etc…).

In Java side i need to do total 5 transactions,in which 4th one is completing workflow process.
All the transactions successfully done (including flowable bpm process completion),

As a final point in Java Application before committing to database, there is a exception got and need to roll back all the transactions (5 transactions…, including bpm flowable commits).

in this scenario, how can i roll back flowable related database?

how this can be takencare as, Java Application always interacts to Flowable BPM with REST API Calls?

Thanks in Advance…,