Announcement Announcement Module
No announcement yet.
Threading in Spring Container Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Threading in Spring Container


    I have the following configuration for RMI Server:

    <beans xmlns="" xmlns:xsi=""
    xmlns:aop="" xsi:schemaLocation="">

    <bean name="initializer" class="org.springframework.remoting.rmi.RmiService Exporter" >
    <property name="serviceName" value="Call"/>
    <property name="service" ref="rmiCall"/>
    <property name="serviceInterface" value="com.istnet.ivr.common.RMICall"/>

    <bean id="rmiCall" class="com.istnet.ivr.rmi.RMICallImpl" >
    <property name="abstractScript" ref="Mainscript" />

    <bean id="Mainscript" class="com.thenewbank.ivr.script.MainScript">
    <property name="manager" ref="application"/>
    <property name="subflows">
    <entry key="Language" value-ref="LanguageSubflow" />

    <bean name="LanguageSubflow" class="com.bab.ivr.subflows.identify.LanguageSelec tSubflow" >
    <property name="subflowName" value="Language"/>
    <property name="callScript" ref="Mainscript"/>


    MainScript is a thread.

    My problem is I want every time a new RMI Client connection to have a separate instance from the MainScript Bean.

    Is this achievable using any known attributes?

    Thanks In Advance

  • #2
    More details for the problem

    When I have tried to run the above code and configuration only one client is able to start the thread. If another client connected in the same time the container will try to use the same RMICallImpl class which starts the MainScript thread again. This will result in "IllegalThreadStateException" Exception.

    The reason is clear to me because the beans scope is singleton. I have tried the new SimpleThreadScope as well but it didn't succeed also and throws a circular dependency error.

    My question is how I can tell the container to initiate a new MainScript Thread for every usage for the RMICallImpl class .

    Any help will be appreciated


    • #3
      I suggest reading the reference documentation on bean scopes. Sounds like you want prototype.


      • #4
        Trying the prototype

        Thanks for the reply

        But I have tried the prototype scope also before but it didn't succeed as well. It seems that I will try the TaskExecutor and I hope it solves my problem.


        • #5

          I'd advice to use java.util.concurrent instead.

          Configure an executor in spring and submit tasks from clients (runnable, callable)