How to Suspend A Process Instance using Service Task

How to Suspend A Process Instance using Service Task.
withing service task I have the following code

RuntimeService runtimeService = Context.getProcessEngineConfiguration().getRuntimeService();
log.info("Suspending {}",execution.getProcessInstanceId());
runtimeService.suspendProcessInstanceById(execution.getProcessInstanceId());

But the process seems to be continuing , as usual even after execution of the Service Task .
I am expecting the process should suspend at the service task itself.

How can I achieve that.

No, that won’t work. The suspension is only checked when calling API’s (e.g. taskService#completeTask), not when the process instance is in the middle of executing. If you want to implement that, you’ll need to make your delegate a wait state (by implementing the ActivityBehavior, calling the suspend method and not leaving the service task).