RangerTransactionService { public void scheduleToExecuteInOwnTransaction(final Runnable task, final long delayInMillis) { try { scheduler.schedule(new Runnable() { @Override public void run() { if (task != null) { try { TransactionTemplate txTemplate = new TransactionTemplate(txManager); txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); txTemplate.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus status) { task.run(); return null; } }); } catch (Exception e) { LOG.error("Failed to commit TransactionService transaction", e); LOG.error("Ignoring..."); } } } }, delayInMillis, MILLISECONDS); } catch (Exception e) { LOG.error("Failed to schedule TransactionService transaction:", e); LOG.error("Ignroing..."); } }  @PostConstruct void init(); @PreDestroy void destroy(); void scheduleToExecuteInOwnTransaction(final Runnable task, final long delayInMillis);  }
@Test public void test3ExecuteAfterTransactionComplete() { rangerTransactionService.scheduleToExecuteInOwnTransaction(task, 1000L); }