@FilipGregor if Optimistic locking exceptions occurred in service tasks or with any async boundaries executions which are in camunda job executor scope will be auto retried with 3 times. For implementing custom retry mechanism for this exception you can try below:
if Optimistic locking exceptions occured in User Task type then you can try with implementing Spring Rest Template retry.