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

BackgroundService and BackgroundTaskService as a way of creating mementos to execute jobs asynchronously

    XMLWordPrintableJSON

Details

    Description

      BackgroundService is the service that creates the mementos, with a default implementation in isis-core.

      usage:

      public void submitInvoices() {
      for(Customer customer: customerRepository.findCustomersToInvoice())

      { backgroundService.execute(customer).submitInvoice(); }

      }

      @javax.inject.Inject
      private BackgroundService backgroundService;

      Here the service creates a javassist proxy through which it can figure out the arguments. The MementoService and BookmarkService can be used to create the memento string (XML).

      ~~~~~~~~~~~~~
      BackgroundTaskService is the service that persists the mementos, with a default implementation in objectstore-jdo. Each persisted BackgroundTask should be associated with the transactionId of the Interaction (see ISIS-660).

      ~~~~
      also:

      • require separate "contributions" service to add in the BackgroundTask collection to the Interaction.

      ~~~~
      NB: the docs should indicate that an alternative implementation for BackgroundTaskService could be webhooks. Per Maurizio's comment:

      a web hook is basically an HTTP callback
      An example of web hook is available on the Google infrastructure, where task longer than 30 sec. are not allowed.
      This is similar to your idea of background service:

      public void calculateInvoices() {
      for(Customer customer: customerRepository.findCustomersToInvoice())

      { Queue queue = QueueFactory.getDefaultQueue(); queue.add(withUrl("/worker").param("id", customer.getId())); }

      }

      Tasks added to the queue will execute by calling the request handler at the URL /worker with the parameter id at a given task rate.

      https://developers.google.com/appengine/docs/java/taskqueue/overview-push

      Attachments

        Activity

          People

            danhaywood Daniel Keir Haywood
            danhaywood Daniel Keir Haywood
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: