【问题标题】:Spring HTTP invoker waits one second before processing next requestSpring HTTP 调用程序在处理下一个请求之前等待一秒钟
【发布时间】:2012-10-09 17:10:41
【问题描述】:

我已经设置了一个 spring http 调用程序示例,如第 20.4 节中的http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/remoting.html 所述

如果我连续执行多个服务调用(请参阅我的 for 循环),虽然服务器在不到 4 毫秒的时间内处理该方法,但单个调用之间的间隔为一秒。

任何想法。

斯蒂芬

这里是配置和调用:

<!-- server side -->
<bean name="configurationServiceExporter"
class="org.springframework.remoting.httpinvoker.SimpleHttpInvokerServiceExporter">
    <property name="service" ref="configurationService" />
    <property name="serviceInterface"
        value="remote.service.ConfigurationService" />
</bean>
<bean id="httpServer"
    class="org.springframework.remoting.support.SimpleHttpServerFactoryBean">
    <property name="contexts">
        <util:map>
                    <entry key="/remoting/ConfigurationService" value-ref="configurationServiceExporter" />
                    </util:map>
    </property>
    <property name="port" value="${port.httpinvoker}" />
</bean>

<!-- client side -->
<bean id="configurationServiceProxy"     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
    <property name="serviceUrl"
        value="http://localhost:7777/remoting/ConfigurationService" />
    <property name="serviceInterface"
        value="remote.service.ConfigurationService" />
</bean>

/** here the service call*/
@Component
public class ServiceConsumer {

private ConfigurationService configurationService;

public void do(){
 for (int i = 0; i < 10; i++) 
    this.configurationService.getConfigurationValue(SMTP_HOST);
}

【问题讨论】:

    标签: java spring spring-remoting httpinvoker


    【解决方案1】:

    我刚刚遇到了同样的问题:

    • 弹簧远程处理
    • “正好”1 秒的延迟
    • Java 7

    很遗憾,我无法找到导致这种奇怪行为的原因,但有一个解决方法:使用码头而不是 SimpleHttpServerFactoryBean

    这归结为稍微更改 xml 配置,具体如何描述 here

    延迟消失了;与在 Java 6 中使用 SimpleHttpServerFactoryBean 相比,触发请求的速度似乎加快了。

    【讨论】:

      【解决方案2】:

      发现问题。它没有连接到 Spring HTTP Invoker。我更新到 Java 7。当我使用 Java 6 运行我的应用程序时,它的工作方式与更新前一样(在请求之间无需等待一秒钟。如果我知道更多信息,我会回来。

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-10
      • 2021-06-06
      • 2023-04-09
      • 2016-08-04
      • 2013-05-01
      相关资源
      最近更新 更多