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

  • Threading in Spring Container

    Dears,

    I have the following configuration for RMI Server:

    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

    <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>

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

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

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

    </beans>

    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

    Comment


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

      Comment


      • #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.

        Comment


        • #5
          java.util.concurrent

          I'd advice to use java.util.concurrent instead. http://download.oracle.com/javase/6/...e-summary.html

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

          Comment

          Working...
          X