class TransactionUtils {

    public static Mono<Void> registerSynchronization(TransactionSynchronization synchronization,
                                                     Function<TransactionSynchronization, Mono<Void>> whenNoTransaction) {<FILL_FUNCTION_BODY>}
}

        return TransactionSynchronizationManager
            .forCurrentTransaction()
            .flatMap(manager -> {
                if (manager.isSynchronizationActive()) {
                    try {
                        manager.registerSynchronization(synchronization);
                    } catch (Throwable err) {
                        log.warn("register TransactionSynchronization [{}] error", synchronization, err);
                        return whenNoTransaction.apply(synchronization);
                    }
                    return Mono.empty();
                } else {
                    log.warn("transaction is not active,execute TransactionSynchronization [{}] immediately.", synchronization);
                    return whenNoTransaction.apply(synchronization);
                }
            })
            .onErrorResume(NoTransactionException.class, err -> whenNoTransaction.apply(synchronization));
    
<no_super_class>