Task Listener for create event called before task persisted to database/context

235 views
Skip to first unread message

Anton

unread,
Mar 27, 2015, 10:46:34 AM3/27/15
to camunda-...@googlegroups.com
Hi,

In TaskListener I want to send notification about task creation to a web page. 
After that the web page refreshes task list by using server call with taskService.taskQuery API,
But the new task does not exists at that moment. It will appear later once I reload a page manually.

Is it possible catch notification right after it is stored in DB and available

Thanks in advance




 

thorben....@camunda.com

unread,
Mar 30, 2015, 3:55:12 AM3/30/15
to camunda-...@googlegroups.com
Hi Anton,

That's not possible via public API.

You can use a TransactionListener though. In your TaskListener, write the following:

public void notify(DelegateTask delegateTask) {
   
   
Context.getCommandContext().getTransactionContext()
     
.addTransactionListener(TransactionState.COMMITTED, new TransactionListener() {

     
@Override
     
public void execute(CommandContext commandContext) {
       
// send your notification here
       
     
}
   
});
 
}

The transaction listener is called once the process engine transaction has been committed.

Disclaimer: This is internal API, meaning we do not guarantee any stability with upcoming releases.

Cheers,
Thorben

Anton

unread,
Mar 30, 2015, 11:52:49 AM3/30/15
to camunda-...@googlegroups.com
I see. Thanks a lot

понедельник, 30 марта 2015 г., 10:55:12 UTC+3 пользователь thorben....@camunda.com написал:
Reply all
Reply to author
Forward
0 new messages