cancel
Showing results for 
Search instead for 
Did you mean: 

Task Created by Timer Boundary

waqses
Champ in-the-making
Champ in-the-making
Hi All,
want to ask is there any way to get the task created by Timer Boundary using service task?

BPMN Example
[img]http://img15.imageshack.us/img15/2480/screenshot20130402at506.png[/img]

User Order.
The worker received the order and must response with "Accept" or "Denied"
If Due, Service task will automatically generate response as "Canceled" and Interrupt the Task.

Here's the case.
I'm using my own tables to show the Order Current Task. In one of the table there's a Task ID field which pointed to the task.
Which is why when User submitted an Order, I insert the params I need to my own table but still there's a Task ID.
So, my question is how to get the "Order Canceled" Task ID while the task is auto generated by timer boundary?

Thank You
7 REPLIES 7

frederikherema1
Star Contributor
Star Contributor
By "Order Canceled", you mean the service-task "Auto generate …"?

If it's a service-task, there is no task-id, only an "activity id", since there is no user-input required for a service-task, no UserTask is create.

waqses
Champ in-the-making
Champ in-the-making
By "Order Canceled", you mean the service-task "Auto generate …"?

If it's a service-task, there is no task-id, only an "activity id", since there is no user-input required for a service-task, no UserTask is create.

Hi frederik and thanks for your reply,
I'm sorry for misguided "Order Canceled". I mean "Confirm Order Canceled".

"Order Canceled" is a status that I need. The service-task "Auto Generate" is generating the params that hold the "Canceled" status and send it to the next task which is "Confirm Order Canceled".

Yeah I know there is no task-id for service-task. What I would get is the task ID for "Confirm Order Canceled".
I already looked at the database, the service-task works just fine and it continue to task "Confirm Order Canceled" and again it works great, the task has been made and appear on ACT tables. But, like I told at the beginning, I'm using other tables that hold the params I need and also the Current Task ID.
Now I need the "Confirm Order Canceled" Task ID that generated automatically and put it in my own tables.

Thank You once again.

frederikherema1
Star Contributor
Star Contributor
Add a task-listener (http://activiti.org/userguide/index.html#taskListeners) on the create-event of the task you're interested in. When it's created, you get a callback with a delegateTask, which exposes it's ID. From here, you can write to your database (best to reuse the transaction activiti uses, in order to prevent your DB to be populated with a task-id that doesn't exist in case something goes wrong in activiti when/after creating the task).

waqses
Champ in-the-making
Champ in-the-making
I'm sorry frederik but which task should I add the task-listener to? "Confirm Order Canceled" or "Receive and Confirm Order" task?

frederikherema1
Star Contributor
Star Contributor
You should add a task-listener to the task you want to retrieve (and store in your DB) the task-id from.

waqses
Champ in-the-making
Champ in-the-making
Thank you so much frederik.
Now I got the Task ID but more problem occurred  :cry:
My Timer Boundary did not work when it reach the Due Date. How to Debug this thing??  :cry:

Here is my Listener Class


class ListenerTaskDue implements TaskListener {

@Override
public void notify(DelegateTask delegateTask) {
  // TODO Auto-generated method stub
  System.out.println(delegateTask.getId());
}
}

I tested it by attaching this to "Received Order" Task and it worked. When the User submitted the order and the workflow moving to "Received Order" Task, it printed the Task ID of "Received Order" Task.
Then I also attached this listener to "Confirm Order Canceled" Task, which is the Task that I want to retrieve the Task ID of it, and I waited for the timer to trigger by its own but nothing happened. The Task is not even moving from "Received Order" Task.
Is there any log for this?

frederikherema1
Star Contributor
Star Contributor
How did you 'test' this? In a live-environment or using a unit-test?

Regardless of what environment, you should validate if the activiti-config defines that de jobExecutor should be activated on startup. If you're using a unit-test, you can use ClockUtil to set the time the engine is using, to force a timer to trigger…