1 2 Previous Next 15 Replies Latest reply on Feb 19, 2016 4:56 AM by paul.robinson

    Compensations API updates


      Some time ago Emmanuel suggested that we could allow using Lambdas for handler implementations in Compensations API. In addition to the currently used approach to provide different class for every different handler and adding it to the annotation so that instance would be created only during confirm/close/compensate steps. This approach could make the API a little less verbose. However, it requires API change and annotations could not be used to register an instance of the handler (annotation only takes a class name).

      During the Narayana f2f meeting tomjenkinson suggested one example and I added a couple. I wrote quick implementations for two of them and they are bellow with the pseudo code. Please give your thoughts on the idea and the examples if in your opinion this would be useful. Other API suggestions would also be appreciated.


      First example ([JBTM-2458] Tom's example from the comment · gytis/narayana@92378de · GitHub:

      BusinessLogic foo = () -> collectionWrapper.updateOne();
      foo(); // annotations on it


      Second example ([JBTM-2458] Think of the possibility to improve Compensations API wit… · gytis/narayana@2ce55f2 · GitHub:

      public interface Action {
          void execute();
      public interface CompensatableAction {
          List<CompensationHandler> getCompensationHandlers();
          List<ConfirmationHandler> getConfirmationHandlers();
          List<TransactionLoggedHandler> getTransactionLoggedHandlers();
          Action getAction();
      public final class CompensatableActionBuilder() {
          CompensatableActionBuilder addCompensationHandler(CompensationHandler compensationHandler);
          CompensatableActionBuilder addConfirmationHandler(ConfirmationHandler confirmationHandler);
          CompensatableActionBuilder addTransactionLoggedHandler(TransactionLoggedHandler transactionLoggedHandler);
          CompensatableActionBuilder addAction(Action action);
          CompensatableAction build();
        1 2 Previous Next