/** * add participant. * * @param hmilyParticipant {@linkplain HmilyParticipant} */ public void enlistParticipant(final HmilyParticipant hmilyParticipant) { if (Objects.isNull(hmilyParticipant)) { return; } Optional.ofNullable(getCurrentTransaction()) .ifPresent(c -> { c.registerParticipant(hmilyParticipant); updateParticipant(c); }); }
/** * when nested transaction add participant. * * @param transId key * @param hmilyParticipant {@linkplain HmilyParticipant} */ public void registerByNested(final String transId, final HmilyParticipant hmilyParticipant) { if (Objects.isNull(hmilyParticipant) || Objects.isNull(hmilyParticipant.getCancelHmilyInvocation()) || Objects.isNull(hmilyParticipant.getConfirmHmilyInvocation())) { return; } final HmilyTransaction hmilyTransaction = HmilyTransactionGuavaCacheManager.getInstance().getHmilyTransaction(transId); Optional.ofNullable(hmilyTransaction) .ifPresent(transaction -> { transaction.registerParticipant(hmilyParticipant); updateParticipant(transaction); }); }
private void executeHandler(final boolean success, final HmilyTransaction currentTransaction, final List<HmilyParticipant> failList) { HmilyTransactionGuavaCacheManager.getInstance().removeByKey(currentTransaction.getTransId()); if (success) { deleteTransaction(currentTransaction); } else { currentTransaction.setHmilyParticipants(failList); updateParticipant(currentTransaction); throw new HmilyRuntimeException(failList.toString()); } }