ExecutionListener cannot get full variables

Hi, everyone:
I have create a simple process via Modeler, and I would like to send email notification with all variables information in each key event to users.

The process has 4 fields inside, requestor(String), goods_name(String), amount(Long), approved(Boolean).

In the first User task, I put one TaskListener on it and the Even type is assigment, listener type is Jave class, name call some_package_name.SendMailToAssigneeListener. This listener can get requestor, goods_name, amount.
In EndEvent part, I put one ExecutionListener on it and the Even type is end, listener type is Jave class, name call some_package_name.SendTaskEndMailListener. When the whole process has been completed, this listener just can get requestor, goods_name, amount instead of all variables.

But when I use eclipse to do some test via Junit, the ExecutionListener seem haven’t invoke when process completed.

Here is the BPMN file: Purchase_test.bpmn (6.6 KB)

Below is ExecutionListener:

public class SendTaskEndMailListener implements ExecutionListener {

public void notify(DelegateExecution execution) throws Exception {
	IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService();
	HistoryService historyService = Context.getProcessEngineConfiguration().getHistoryService();
    String requestor = (String) execution.getVariable("requestor");			
    User user = identityService.createUserQuery().userId(requestor).singleResult();
    String executionId = execution.getId();
    
    if (user != null) {
          // Get Email Address from User Profile
          String recipient = user.getEmail();
                    	          
          List<HistoricVariableInstance> list = historyService
        		  .createHistoricVariableInstanceQuery()
        		  .executionIdIn(executionId)
        		  .list();
          
          System.out.println("Start check VariableInstance...");
		  System.out.println("Variable list size========="+list.size());
		  for(int i=0;i<list.size();i++) {
				HistoricVariableInstance hv = list.get(i);
				String name = hv.getName();
				String value = hv.getValue().toString();
				System.out.println("name==="+name+", value==="+value);
			}
	}
}

}

This looks to be a issue with transactions/save points. You are running your listener before your variables have actually saved to the DB. So you need to run your notification code after the transaction. You can typically do this with setting async After on the task, then executing your notification code as part of a listener on the sequence-flow/Arrow coming out of the Task.

Thank you for your help, I will try it.