class TaskResponseService {

    @PreDestroy
    public void stop(){
        this.taskResponseWorker.interrupt();
        if(!eventQueue.isEmpty()){
            List<TaskResponseEvent> remainEvents = new ArrayList<>(eventQueue.size());
            eventQueue.drainTo(remainEvents);
            for(TaskResponseEvent event : remainEvents){
                this.persist(event);
            }
        }
    }

}