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

  • Handling Multiple Requests


    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...
    <bean id="payloadMapping" class="">
    <property name="defaultEndpoint" ref="transformationEndpoint"/> <!-- extends AbstractDomPayloadEndpoint -->
    <property name="interceptors">
    	<ref local="validatingInterceptor"/>
    	<ref local="loggingInterceptor"/>
    <bean id="transformationEndpoint" class=""> 
    	<!-- transformationService has a process() method called by the invokeInternal(Element requestElement, Document document) 
    		method of transformationEndpoint -->
    	<property name="transformationService" ref="transformationService"/> 
    <bean id="transformationService" class="">
    	<property name="xmlp" ref="transformer.XMLProcessor"/> <!-- custom XML Processor -->
    	<property name="httpTranslator" ref="httpTranslator"/> <!-- Class using Apache HttpClient -->
    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,

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


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



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


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