get thread id for async task in jBPM.
rsmagdum Mar 4, 2014 3:12 AMHi, i have modified given UserCommand class in examples as follows -
public class UserCommand implements Command{
private static final Logger logger = LoggerFactory.getLogger(UserCommand.class);
public ExecutionResults execute(CommandContext ctx) {
logger.info("Command executed on executor with data {}", ctx.getData());
logger.info("Thread ID : ",Thread.currentThread().getId());
WorkItem workItem = (WorkItem) ctx.getData("workItem");
User user = (User) workItem.getParameter("UserIn");
user.setName(user.getName() + "_m_"+ Thread.currentThread().getId());
Thread t = Thread.currentThread();
t.setName(user.getName());
logger.info("Thread Name: ",t.getName());
logger.info("Thread ID: ",t.getId());
ExecutionResults executionResults = new ExecutionResults();
executionResults.setData("UserOut", user);
return executionResults;
}
}
I call this from attached bpmn with singleton strategy.
But Thread Name , Thread ID prints nothing in logs
13:21:11,233 INFO [org.jbpm.examples.cmd.UserCommand] (pool-19-thread-1) Command executed on executor with data {deploymentId=org.jbpm.example:async-examples:2.4, workItem=WorkItem 287 [name=async, state=0, processInstanceId=185, parameters{TaskName=async, UserIn=[Name=rahul, age=20], CommandClass=org.jbpm.examples.cmd.UserCommand}], processInstanceId=185, businessKey=185:287, callbacks=org.jbpm.executor.impl.wih.AsyncWorkItemHandlerCmdCallback}
13:21:11,251 INFO [org.jbpm.examples.cmd.UserCommand] (pool-19-thread-1) Thread ID :
13:21:11,253 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Thread Name:
13:21:11,254 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Thread ID:
13:21:14,225 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Command executed on executor with data {deploymentId=org.jbpm.example:async-examples:2.4, workItem=WorkItem 288 [name=async, state=0, processInstanceId=185, parameters{TaskName=async, UserIn=[Name=rahul, age=20], CommandClass=org.jbpm.examples.cmd.UserCommand}], processInstanceId=185, businessKey=185:288, callbacks=org.jbpm.executor.impl.wih.AsyncWorkItemHandlerCmdCallback}
13:21:14,247 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Thread ID :
13:21:14,250 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Thread Name:
13:21:14,251 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Thread ID:
13:21:17,229 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Command executed on executor with data {deploymentId=org.jbpm.example:async-examples:2.4, workItem=WorkItem 289 [name=async, state=0, processInstanceId=185, parameters{TaskName=async, UserIn=[Name=rahul, age=20], CommandClass=org.jbpm.examples.cmd.UserCommand}], processInstanceId=185, businessKey=185:289, callbacks=org.jbpm.executor.impl.wih.AsyncWorkItemHandlerCmdCallback}
13:21:17,250 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Thread ID :
13:21:17,251 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Thread Name:
13:21:17,252 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Thread ID:
13:21:20,227 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Command executed on executor with data {deploymentId=org.jbpm.example:async-examples:2.4, workItem=WorkItem 290 [name=async, state=0, processInstanceId=185, parameters{TaskName=async, UserIn=[Name=rahul, age=20], CommandClass=org.jbpm.examples.cmd.UserCommand}], processInstanceId=185, businessKey=185:290, callbacks=org.jbpm.executor.impl.wih.AsyncWorkItemHandlerCmdCallback}
13:21:20,241 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Thread ID :
13:21:20,243 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Thread Name:
13:21:20,245 INFO [org.jbpm.examples.cmd.UserCommand] (rahul_m_176) Thread ID:
Why is it so? How i can identify that async task is running as a separate technical thread?