No of times an activity is executed for a process instance

I have a bpmn flow like this

Here after the HTTP task , if the status is NOT CONFIRMED , it has to re execute that HTTP task for at least 5 times.(specified by retry count < 5 ) .If retry_count > 5 it has to go for a manual action by a user task.

Is there any way , to get the count , No. of times an activity has been executed so that i can delegate the task for a manual action , as showed in the bpmn image above.

Thanks.

The easiest implementation is keeping a counter variable. Then, use an exclusive gateway checking that counter to loop back or continue.

you mean counter variable at the execution variable layer/ prcoess-instance-variable layer or at the customer http request response layer?