I am trying to trigger a Task Runner through Java in Hybris 5.3
This is my Controller where I Trigger the task:
final TestDataModel dataModel = *save data in model*
dataModel .setRunnerBean("responseTaskRunner");
final TaskConditionModel conditionModel = modelService.create(TaskConditionModel.class);
final String uid = "Task" + System.currentTimeMillis();
conditionModel.setUniqueID(uid);
dataModel .setConditions(Collections.singleton(conditionModel));
// Start the task in 1 second
dataModel.setExecutionDate(new Date(System.currentTimeMillis() + 1000));
taskService.scheduleTask(gkaRequestBAPIdataModel);
taskService.triggerEvent(uid);
I get the error:
"[DefaultTaskService] Failed to retrieve lock on task #8796617360968. Skipping it."
while I try to trigger the task. Basically the log inside the Task Runner is not being printed as the Task Runner is not being hit.
I gave "Deployment table" name while creating the DataModel Bean which extends Task. Looks like we should not give deployment table name. My Code was all okay.
I think you are mixing time based & event based Trigger.
Time-based: If you want to execute your action in a timely manner then you can scheduleTask like..
Event-based: If you want to execute your action on some event then your code would be like
To trigger the event
Read more details here