Lookup Timer Due date for a Boundary event from Task Create Listener

Hi @patrick.corbett,

the query can’t find the timer because it isn’t committed yet. The timer is created in the same transaction as the listener is invoked. You can use a transaction listener to resolve the issue:

public class MyTaskListener implements TaskListener
{
    public void notify(final DelegateTask delegateTask)
    {
        TransactionContext transactionContext = Context.getCommandContext().getTransactionContext();
        transactionContext.addTransactionListener(TransactionState.COMMITTED, new TransactionListener()
        {
            public void execute(CommandContext commandContext)
            {
                ManagementService managementService = delegateTask.getProcessEngineServices().getManagementService();

                List<Job> timers = managementService.createJobQuery().timers().list();

                for (Job timer : timers)
                {
                    Date duedate = timer.getDuedate();
                    // ...
                }

            }
        });
    }
}

Does this help you?

Best regards,
Philipp

1 Like