Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-11721

Provide base class to help managing long running listeners

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.7.2
    • Component/s: Core

      Description

      The use cases

      There are several uses cases that may justify to have long running asynchronous listeners.

      This includes :

      • a listeners that does I/O intensive processing
        • ZIP/ Unzip, Copy ...
      • a listener that does big conversion
        • Video processing, Image processing ...
      • a listener that calls a webservice that may take time to return
        • OCR, Virus Scan ...

      the problems

      By default, for simplicity reasons, the listeners are queued and executed in Work that will handle :
      1. begin TX + open CoreSession
      2. refetch Event data with new CoreSession (i.e : reconnect the EventBundle)
      3. comit or rollback the transaction

      This means that having long running listeners leads to having long running transactions.

      As is, it can raise several issues :

      • Database locks :
        • resources are locked during Transaction
      • Unchecked Dirty updates :
        • 2 listeners may update the same doc at the same time and have overlapping processing that allows to create dirty updates

      possible solution

      The proposed solution is to split the listener execution in 3 sub-steps :

      1. pre-processing (inside a Transaction)

      • should be fast
      • can access the CoreSession

      2. long running (outside a transaction)

      • can take a long time
      • must not access any transactional resources (they must have been fetched by the pre processing step)

      3. post processing (inside a Transaction)

      • should be fast
      • can access the CoreSession

      I attach here a sample base class for this idea.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: