Uploaded image for project: 'JBeret'
  1. JBeret
  2. JBERET-45

Share expensive resources between reader and writer and even between steps

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 1.0.1.CR1
    • 1.0.1.Beta
    • jberet-support
    • None

      Some resources are expensive to create, like MongoClient, JsonFactory, and so should be shared between the reader class and the corresponding writer class if they are can be safely shared. Sometimes, they cannot be shared, for example, the writer writes to a different mongodb instance running in a different host.

      If a particular resource in various steps within a job are configured the same way, it should be shared.

      How to pass a resource (MongoClient, JsonFactory, etc) from reader to writer?

      • store it in ThreadLocal, but how can we share the same MongoClient among different threads/partitions? We dont' want each partition to create a new MongoClient.
      • maintain a ConcurrentMap, with jobName as the key, to store MongoClient. It seems com.mongodb.Mongo.Holder already implements such ConcurrentMap for caching MongoClient.
      • store it in JNDI as a custom resource, if running in WildFly, and jberet-support should have an option to allow JsonFactory to be looked up via jndi instead of instantiated by application itself.

            cfang@redhat.com Cheng Fang
            cfang@redhat.com Cheng Fang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: