2 Replies Latest reply on Dec 10, 2014 1:22 PM by ozkin

    One instance or many

    ozkin

      Hi, is that correct that in SY there is always only one instance of every binding, reference and component defined in an application?

       

      And if so, all the requests which are targeted to one (same) component (bean, camel..) are always handled sequentially and never concurrently?

       

      Just trying to figure out if I may get any concurrency related problems when handling big amount of requests by my component..

        • 1. Re: One instance or many
          kcbabo

          Bindings are designed to handle concurrent requests, so no issues there.  The same thing is true for implementation components, but may not be the case for your service implementation depending on how you write it.  For example, member variables in your bean service implementation class will not be guarded from concurrent access by the container - the implementation is assumed to be stateless.  If you need to store state specific to a request in a member var, then consider synchronizing access to it (bummer as it serializes concurrent requests), pushing it into a ThreadLocal (this is how we handle injected SY vars like Context), or by attaching it as a context property to the exchange.

          • 2. Re: One instance or many
            ozkin

            Thanks Keith. Eventually I figured it out during my testing. Requests are handled concurrently and implementation components are stateless. Originally I was curious if SY creates only one or may create multiple instances of an implementation component. I understood it is always only one.