Uploaded image for project: 'Causeway'
  1. Causeway
  2. CAUSEWAY-1960

Action background execution: provide built-in default implementation

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.0.0-M3
    • Core
    • None

    Description

      We want this code to run out-of the box (without the need for developers to provide their own implementation of BackgroundCommandService) ...

      @Inject BackgroundService backgroundService;
      @Inject RepositoryService repositoryService;
      @Inject MessageService messageService;
      
      @Action
      public SimpleObject runInBackground(){
          backgroundService.execute(this).backgroundTask();
          return this;
      }
          
      @Programmatic
      public void backgroundTask(){
          messageService.informUser("backgroundTask started");	
      
          try {
              Thread.sleep(8000); // wait 8s
          } catch (InterruptedException e) {
              e.printStackTrace();
          }	
      	
          val dummy = new SimpleObject();
          dummy.setName("Dummy");
      	
          repositoryService.persist(dummy);
      	
          messageService.informUser("backgroundTask finished");	
      }
      

      We solve this using a default ExecutorService to run Action invocations in the background.

      Attachments

        Issue Links

          Activity

            People

              hobrom Andi Huber
              hobrom Andi Huber
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: