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

  • Handling Multiple Requests

    Hi

    I'm using Spring WS and I have been trying to get my web service to handle multiple requests simultaneously (approx load : 20-30 users at a time).

    To be more specific, I have a singleton PayloadRootQNameEndpointMapping which has a defaultEndpoint (class that extends AbstractDomPayloadEndpoint). The endPoint class's invokeInternal() calls the process() (which has the business logic, so to speak) method on my transformationService class.

    Something on these lines...
    Code:
    <bean id="payloadMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
    <property name="defaultEndpoint" ref="transformationEndpoint"/> <!-- extends AbstractDomPayloadEndpoint -->
    <property name="interceptors">
        <list>
    	<ref local="validatingInterceptor"/>
    	<ref local="loggingInterceptor"/>
        </list>
    </property>
    </bean>
    
    <bean id="transformationEndpoint" class="com.xxx.ws.endpoint.TransformationEndpoint"> 
    	<!-- transformationService has a process() method called by the invokeInternal(Element requestElement, Document document) 
    		method of transformationEndpoint -->
    	<property name="transformationService" ref="transformationService"/> 
    </bean>
    
    <bean id="transformationService" class="com.xxx.ws.transform.impl.TransformationServiceImpl">
    	<property name="xmlp" ref="transformer.XMLProcessor"/> <!-- custom XML Processor -->
    	<property name="httpTranslator" ref="httpTranslator"/> <!-- Class using Apache HttpClient -->
    </bean>
    Now, whenever I hit the service simultaneously, I get errors. Synchronizing the transformationService.process() method makes it behave decently, but is
    obviously not the desired solution under load. To handle this situation, do I use lookup method injection to create multiple copies of, say, transformationEndpoint
    for every request? I'm not really sure about what to do here.

    Can you help?

    Thanks in advance,
    Rajiv

    <Spring Newbie Disclaimer>
    I am fully aware of and wholly responsible for my ignorance of Spring. Forgiveness humbly requested.
    </Spring Newbie Disclaimer>

  • #2
    What does transformationService.process() do? It seems like you are using objects in that method which aren't thread safe...

    Comment


    • #3
      No shared variables

      Hi Arjen
      I refactored the code to avoid sharing variables. Currently, each thread accessing the process() method has its own local copy of variables except for certain utility classes that have to no data fields.

      This works but I also want to understand if app performance would be bad if I had multiple requests ( >20-30 at once, ~ 5-6 objects per thread, including some XML processing). My question was more around trying to figure out a strategy for a web service to handle this cleanly.

      Thanks,
      Rajiv

      Comment


      • #4
        Ok, I understand now.

        Typically, just like in Spring-MVC, endpoints are shared, threadsafe, singleton instandes. Of course, you can also use prototypes, but that makes the application less scalable.

        Comment


        • #5
          That's exactly what I needed to know. Thanks.

          Comment

          Working...
          X