Announcement Announcement Module
Collapse
No announcement yet.
Setting a timeout for HTTP Invokers Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting a timeout for HTTP Invokers

    In my current application, I'm exposing a remote service via Spring's HTTP Invoker. This service is a search engine which accepts parameters and returns a result object.

    Under certain circumstances, the search engine may not be available or may be under heavy load. In either circumstance, I'd like to define a timeout on the client side so that the client will never wait for more than X seconds for a response.

    I know that it's possible to use a timer thread on the client side to enforce a timeout but I'd rather not have to incur the expense of creating a timer thread for every remote call.

    Is there a way to either define a transaction timeout for the entire remote call or utilize the timeout methods of the underlying HTTP client to achieve this?

    Thanks.

    - khill

  • #2
    Use Commons HTTP Client

    If you use the CommonsHttpInvokerRequestExecutor, you can configure a timeout for the underlying HttpClient. Please check the JavaDocs.

    -Petter-

    Comment


    • #3
      CommonsHttpInvokerRequestExecutor setting timeout?

      Hi,

      I am looking for an example of how to do this...

      I have got...

      <property name="httpInvokerRequestExecutor">
      <bean class="org.springframework.remoting.httpinvoker.Co mmonsHttpInvokerRequestExecutor">
      <property name="http.socket.timeout">
      <value>1000</value>
      </property>
      <property name="http.connection.timeout">
      <value>1000</value>
      </property>
      </bean>
      </property>

      which picks up the httpInvokerRequestExecutor fine.. but it still uses the defaults...

      Has anyone done this successfully?

      Comment


      • #4
        I'm not sure if the following works.

        <property name="httpInvokerRequestExecutor">
        <bean class="org.springframework.remoting.httpinvoker.Co mmonsHttpInvokerRequestExecutor">
        <property name="httpClient">
        <bean class="org.apache.commons.httpclient.HttpClient">
        <property name="params">
        <bean class="org.apache.commons.httpclient.params.HttpCl ientParams">
        <property name="soTimeout">
        <value>60000</value>
        </property>
        </bean>
        </property>
        </bean>
        </property>
        </bean>
        </property>

        Comment


        • #5
          Cheap wholesale switchblade knives

          rfhnkmdctychgvjvjhbjhb hnvvuhgb

          Comment


          • #6
            Use the &quot;readTimeout&quot; property.

            <property name="httpInvokerRequestExecutor">
            <bean class="org.springframework.remoting.httpinvoker.Co mmonsHttpInvokerRequestExecutor">
            <property name="readTimeout" value="0" />
            </bean>
            </property>

            It will effectively turn off timeout, if you want to increase the timeout, just turn the "0" to something larger in milliseconds that meets your needs. The default is 60000 ms (i.e. 1 min).

            You'll need to use at least 2.5.

            Comment

            Working...
            X