To set the attribute isForCompensation=true for compensation handler

As per docs the Compensation Task type config:

To declare an activity to be a compensation handler, we need to set the attribute isForCompensation=“true”

BPMN xml attribute like:
serviceTask id=“undoBookHotel” isForCompensation=“true” camunda:class=“…”

But I didn’t found a option to set value for “isForCompensation” and “camunda:class

What is the alternative solution?

Why do you think you need this setting?

we need to implement the compensation logic right in this attribute “camunda:class”.

if we are not setting this flag “isForCompensation=true” how process engine will aware that it was compensation handler?

It knows simply because it’s a compensation event linked to a compensation task.
So if you throw a compensation and that task has been completed the corresponding compensation event will trigger the compensation task.

Also if you want to add a java class - convert it to a service task.