1 of 1 people found this helpful
One of possible solution to that would be to use following method from TaskClient:
public void getTaskByWorkItemId(long workItemId, GetTaskResponseHandler responseHandler)
if you can include work item id while sending the link. You could get work item id with onExit-script of the human task - set it as process variable.
Then use that work item id to query for task.
If that is not good for your case you can always use the generic query method from TaskClient.
Thanks for the response.
I would prefer to use the task client's query method so that I could avoid exposing jBPM specific information like work item IDs. The problem is, what do I query? As far as I can tell, jBPM stores all custom data as BLOBs which are not easily accessible by queries. How do I associate work items with a new user name in a way that I can later query.
Note that we are talking about Task Server and there are more data you can access in regular queries on data base.
If it comes to the exposing jBPM specific information, I don't think you can completely avoid that. One thing you could query on is processInstanceId that is stored in the task server. Depending on your process definition it could be that at a given point in time only one task will be created for process instance id.
In addition to that, you could use task comments to place some meaningful information that would help you to find the right tasks.
Here is a nice overview of the data base schemas for the engine and task server:http://community.jboss.org/message/627783
Some Times you need to expose the WorkItemID or wrap that information using a Business Object that will maintain the information about the process execution and its external interactions to keep track of what is happening
We decided to include the work item id in the email link. Not perfect but not really that bad either. One remaining problem involves the determination of the work item id when sending the email. Ideally the process would look something like this:
1) user initiates the registration
2) system sends a verification email
3) the process transitions to the human task, waiting for the user to follow the link, confirm the registration, etc.
The problem is that we need to know the work item id for the human task in step 2, in order to include it in the email. But, the task is only created in step 3. The solution we found was to combine steps 2 and 3. We subclassed CommandBasedWSHumanTaskHandler and overrode the executeItem method to send the email right before proceeding with the human task. At that point the work item id is known and we can include it in the email. It works fine but feels a little awkward. If anyone has a more elegant solution, I'd love to hear it.
In any case, thanks for all the replies.
Yes, it's sounds a little bit awkward. You can also do something similar without extending anything and is using the onEntry/onExit extensions that allows you to execute a piece of code when the process is entering or leaving an activity.
But.... that makes me think and wonder, why do you need the workItemId?
If the session is alive, instead of completing the work item you should be completing the human task, and the human task server will be in charge of notifying the process to continue right?
Tommer, for what you describe human task notifications sound like perfect fit. They are part of deadlines configuration of a task. To be more precise start deadline. In general, start deadline is reached when task is not started before the given time expires. There are two options for deadline escalation:
Both can be used at the same time, but in your case notification is more interesting.
Notification (email notification) can be sent to some recipients that are not assigned directly to a task, which could be what you are looking for since there is no user registered at the moment.
Unfortunately there is no out of the box support to define deadlines in BPMN2, at least I do not know it. So extension of *HumanTaskHandler class will be required to setup deadlines on the task. Some additional configuration is needed on Task Server side as well, for details about task server please have a look at: https://github.com/droolsjbpm/jbpm/blob/master/jbpm-human-task/src/test/java/org/jbpm/task/service/TaskServiceDeadlinesBaseTest.java