JBoss Community

Using TaskService directly

created by tlucz in jBPM - View the full discussion

Hi,

I've started using jBPM 5.3.0.Final. I want to use HumanTasks embedded in my application. So basing on thread:

 

https://community.jboss.org/thread/162963?start=15&tstart=1

 

I created my own LocalHumanTaskHandler where in constructor TaskServiceSession is created:

 

        TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());

        taskSession = taskService.createSession();

        this.session=session;

 

ExecuteWorkItem method is taken from GenericCommandBasedWSHumanTaskHandler. The only change is to invoke:

 

taskSession.addTask(task, content);

 

instead of:

 

client.addTask(task, content, new TaskAddedHandler(workItem.getId()));

 

 

I can work with HT in a way e.g.:

 

List<TaskSummary> taskList = wrapper.taskServiceSession.getTasksAssignedAsPotentialOwner("john", "en-UK");

 

wrapper.taskServiceSession.taskOperation(Operation.Complete, lastTask.getId(), "john", null, null, null);

 

 

It almost works correctly, task data is stored in DB but process instance is not updated after complete task. The problem is how can I register TaskEventHandlers. In GenericCommandBasedWSHumanTaskHandler there is a method:

 

private void registerTaskEventHandlers() {

        TaskEventKey key = new TaskEventKey(TaskCompletedEvent.class, -1);

        TaskCompletedHandler eventResponseHandler = new TaskCompletedHandler();

        client.registerForEvent(key, false, eventResponseHandler);

        key = new TaskEventKey(TaskFailedEvent.class, -1);

        client.registerForEvent(key, false, eventResponseHandler);

        key = new TaskEventKey(TaskSkippedEvent.class, -1);

        client.registerForEvent(key, false, eventResponseHandler);

    }

 

but I have no client so I have no possibility to register these events. Also TaskServiceSession object has no method to register ResponseHandlers. How can I resolve it?

 

I also read thread

https://community.jboss.org/thread/204619?tstart=270

but in this case I have no idea how to create TaskService which I need to pass to LocalHTWorkItemHandler.

 

Thanks in advance for any help.

kr,

Tadeusz

Reply to this message by going to Community

Start a new discussion in jBPM at Community