0
실행 중에 하트 비트를 전송하는 다음과 같은 트랜잭션이 있습니다. 그러나 어떤 상황에서는 하트 비트 타이머가 절대로 멈추지 않으며 시스템은 트랜잭션이 실행 중이 지 않아도 하트 비트를 계속 보냅니다. 여기서 뭔가 잘못하고있는거야? 심장 박동 타이머를 멈추는 더 확실한 방법이 있습니까 (jboss를 멈추는 것 외에는)?finally 트랜잭션에서 {timer.cancel();}에 도달하지 않음
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@Asynchronous
public void performUpdate(long requestSettingId) throws exception {
try {
// At this line a new Thread will be created
final Timer timer = new Timer();
// send the first heartbeat
workerService.sendHeartBeat(requestSettingId);
// At this line a new Thread will be created
timer.schedule(new HeartbeatTask(setting.getId()), heartBeatInterval, heartBeatInterval);
try {
//Perform update
//
} finally {
// terminate the HeartbeatTask
timer.cancel();
} catch (Exception e) {
//Notify the task owner of the exception
}
}
}
정말이에요? 나는 당신이 당신의 괄호를 뒤섞 었다고 생각한다. – Aurand
왜 다른 중첩 시도를 사용하고 있습니까? 어쨌든? timer.schedule()이 실제로 종료 되었습니까? –
@Aurand, 죄송합니다. 복사하고 붙여 넣을 때 대괄호를 놓쳤습니다. 코드가 컴파일되고 99 %의 시간 동안 정상적으로 작동합니다. 그러나 드문 경우지만 하트 비트 타이머가 멈추지 않습니다. –