Announcement Announcement Module
Collapse
No announcement yet.
Thread saftey Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Thread saftey

    Hi I'm not sure how to ensure thread safety in SI.

    For example how do I find out if a Spring Integration out-of box component is thread safe and how do I manage my own beans to ensure they can be used in concurrent execution environments? Is there any out of the box support for this (for example bean pooling ?), in SI or is it a case of defining good practice (In which case are there any good practice pointers?)

    Or is this a core Spring concern (I'm coming into Spring via Spring Integration).

    I can't find any discussion of this in SI reference docs and nothing obvious in this forum - am I just missing something ?

  • #2
    When using SI assume your services will be called concurrently. You do not have to worry about the thread safety of SI components (i.e. if a component isn't threadsafe you should log an issue). Thread safety concerns should be documented in the javadoc, so if you are missing something you should create a documentation issue.

    To make your own components threadsafe the easiest path to go is: stateless services passing around immutable objects.

    One additional remark to make is that you do not have to be concerned about the threadsafety around initialization (setter invocations). Initialization will be done by Spring in a single thread before Spring Integration starts any pollers. As long as the dependencies of your services are effectively immutable (as defined by Goetz et al).

    Basically, keep your code simple and log SI bugs if you run into (unlikely) threading issues.

    Comment


    • #3
      I just filed this issue dealing with thread-safety.

      http://jira.springframework.org/browse/INT-623

      Comment


      • #4
        I just added a comment on that issue. I would like to know a bit more about the use-case... (in case it may be related to the other issue that I pointed to in that comment). Or, if you can at least provide an example where this is happening, please attach that to the issue.

        Thank you.
        -Mark

        Comment


        • #5
          We are trying to narrow down the issue now. Sorry for the misfire. Your suggestion seems like a good possibility. We should know more tomorrow.

          Comment


          • #6
            No worries. Please do post back here (and/or the JIRA issue) with whatever you find.

            Comment


            • #7
              Originally posted by jpeterson View Post
              Sorry for the misfire.
              I was a bit rough on the jira, quoting javadoc and all. I did that only to make the information clear and concise for those that might come up with the same error.

              I don't want to imply in any way that you shouldn't create the issue if you run into a problem. Logging a bug even if you suspect it might be invalid is a very good way to track the investigation. You don't need to apologize for it. Please don't stop.

              As a courtesy and you can look for duplicates, but even if you don't have time for that it's better to raise a false alarm than to ignore a potential bug.

              Thanks for your contribution.

              Comment

              Working...
              X