2 Replies Latest reply on Apr 13, 2011 5:10 AM by lvdberg

    Concurrent Access to Seam Component

    freakwave10

      Hi all,


      sorry for my lack of the technical details here, but still trying to learn.
      To simplify lets assume I have the following POJO components:


      - gateway (EventScope)
      - commandScheduler (ApplicationScope)
      - job (EventScope)


      now the job is executed by quartz. I am setting up everything in the commandScheduler and creating a job with a reference to the gateway.
      Since I am storing the gateway in a class variable in the commandScheduler, this eventscope has basically the same lifecycle as the whole application scope.


      Now my questions:
      Since all jobs basically share the same gateway instance, how does this affect my performance? Could I run into concurrency problems? This is almost like a pojo singleton.
      On the other hand I could always create a new gateway instance for every job and pass it to the new job, but this is also kind of expensive.
      Finally this could be a good use case for a stateless session bean.


      Thanks a lot for some theoretical insight.


      Wolfgang






        • 1. Re: Concurrent Access to Seam Component
          freakwave10

          Perhaps I should add that my gateway does not have any shared instance variables, only local variables in the methods.

          • 2. Re: Concurrent Access to Seam Component
            lvdberg

            Hi,


            I know that Seam synchronizes access to beans and besides that the Seam framework provides for a Synchronizer (annotation) which takes care of async access.


            I prefer NOT to depend on the framework for this specific area, but to build a simple synchronized Queue myself, since Java 5 there is a concurrency package which simplifies the task substantially (basically a few lines). This allows you to add things like priorities also, something which Seam doesn' have at the moment.


            Leo