spring-integration - MarshallingWebServiceOutboundGateway 第一次请求占用太多
问题描述
我们有很多可以用来连接的soap服务,每次第一次连接到同一个服务都需要花费大量时间从集成开始,随后的请求会迅速减少60%的响应时间。
解析JAXB绑定初始化
@Configuration
public interface WSCommons {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
@Bean
static Jaxb2Marshaller jaxb2Marshaller() {
marshaller.setPackagesToScan("com.abc");
return marshaller;
}
}
这需要大量的第一个请求来扫描所有内容并创建编组器。
但,
一旦 Bean 被初始化,它就可以快速处理少量请求。当服务流空闲一段时间并且请求再次开始流动时,MarshallingWebServiceOutboundGateway 滞后非常糟糕。
Jaxb2Marshaller 是静态的,在这种情况下它应该停止重新初始化。
任何输入表示赞赏,可能在初始化时做错了。
谢谢
解决方案
我不相信它会@Configuration
在界面上使用。因此,您的@Bean
forJaxb2Marshaller
是不可见的。
您需要考虑将您的 @Configuration
设置为 aclass
并将其static
从 bean 定义中删除。
有Jaxb2Marshaller
一个选项,如:
/**
* Set whether to lazily initialize the {@link JAXBContext} for this marshaller.
* Default is {@code false} to initialize on startup; can be switched to {@code true}.
* <p>Early initialization just applies if {@link #afterPropertiesSet()} is called.
*/
public void setLazyInit(boolean lazyInit) {
这是false
默认情况下,因此afterPropertiesSet()
在正常的 bean 初始化阶段调用。所有的包都在这里扫描,一个完整的包JAXBContext
被缓存在Jaxb2Marshaller
bean 中。
推荐阅读
- python - 获取包含给定子字符串的所有元素的索引
- ios - iOS网络应用程序黑色半透明在底部留下一个白条?
- swift - 过滤任何类型的可变参数
- android-studio - 使用按钮调用第二个活动时出错
- reactjs - 在组件内调用多个操作时 Redux Reducer 的行为
- sql - 特定日期,但根据 GETDATE() 增加年份
- angular - 将大型 DTO 映射到 Angular 中的反应形式
- hyperledger-fabric - Hyperledger Fabric 1.4 链码实例化压缩器错误
- latex - 段落开头的空格
- date - 如何在 DatePickerTimeline 中设置结束日期