Rai*_*ndo 8 soap cxf apache-camel
我正在使用Apache Camel根据请求消息中的某个属性路由SOAP请求.该消息被针对正则表达式匹配,并且如果找到匹配所述请求将被路由到"calldestination1",如果没有,它将被路由到"calldestination2".
我正在使用以下配置:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<!-- ... -->
<cxf:cxfEndpoint id="testEndpointTest"
address="http://localhost:8080/testEndpoint"
endpointName="s:testEndpoint_Port"
serviceName="s:testEndpoint"
wsdlURL="wsdl/testEndpoint.wsdl"
xmlns:s="http://teste.com/testEndpoint"/>
<!-- ... -->
<camelContext xmlns="http://camel.apache.org/schema/spring">
<endpoint id="calldestination1" uri="http://localhost:8080/destination1?bridgeEndpoint=true&throwExceptionOnFailure=false"/>
<endpoint id="calldestination2" uri="http://localhost:8080/destination2?bridgeEndpoint=true&throwExceptionOnFailure=false"/>
<route streamCache="true">
<!--CXF consumer using MESSAGE format-->
<from uri="cxf:bean:testEndpointTest?dataFormat=MESSAGE"/>
<choice>
<when>
<simple>${bodyAs(java.lang.String)} regex ${properties:router.regex}</simple>
<to uri="calldestination1"/>
</when>
<otherwise>
<to uri="calldestination2"/>
</otherwise>
</choice>
</route>
</camelContext>
Run Code Online (Sandbox Code Playgroud)
当运行"calldestination2"的目标服务器处于加载状态时,请求可能需要大约1150ms才能响应.Apache Camel似乎没有很好地处理这个问题.
为了复制这种行为,我使用带有延迟(OnRequest Script)和jmeter的SOAP MockService的SoapUI.拳头我没有延迟地对SoapUI MockService进行测试,然后延迟1100ms.
然后我配置Apache Camel将请求路由到SoapUI服务并重复测试.
JMeter - > SoapUI - 0ms延迟
〜每秒1200个请求; 25ms请求平均值; 0%错误
JMeter - > SoapUI - 1100ms延迟
〜每秒100个请求; 平均需求1128ms; 0%错误
JMeter - > Apache Camel - > SoapUI - 0ms延迟
〜每秒420个请求; 请求平均285ms; 0%错误
JMeter - > Apache Camel - > SoapUI - 1100ms延迟
〜每秒8个请求; 平均请求14800ms; 超时错误率为97.23%
Apache Camel中的超时设置为30秒.
为什么Apache Camel在最后一种情况下具有如此低的性能,我该如何改进呢?
编辑1:
我在GitHub中创建了一个存储库,其中包含Apache Camel项目,SoapUI模拟服务和jmeter测试,以便于测试.
基本问题
此类问题始终是资源问题。只要所有组件都有足够的资源并快速响应,一切都很好。一旦其中一个遇到资源限制,它就会变得很慢。
在 JMeter-SoapUI 场景中,SoapUI 的有意延迟由 JMeter处理。由于 SoapUI 需要超过一秒的时间来响应,因此 JMeter 请求此时保持打开状态。如果用于请求的 JMeter 线程池已耗尽(所有线程都在等待 SoapUI 的响应),则它无法进一步扩展。根据您的测量,线程池大小可能为 100。
然后你把骆驼放在中间。这样你就引入了新的线程池。必须有一个用于接收请求 (CXF),也可能有一个用于发送请求 (Camel HTTP)。现在,SoapUI 延迟也必须由这些池处理。同样的情况,但现在 Camel 组件的线程池是限制。
假设 Camel HTTP 请求的线程池默认为 10。JMeter 开始发送请求。如果JMeter 发送新请求的速度比 SoapUI 响应的速度快,则向 SoapUI 发送 HTTP 请求的 10 个线程会非常快且全部忙(等待 SoapUI)。
JMeter 的新请求到达,但在其中一个线程再次空闲之前,不可能向 SoapUI 发出新的 HTTP 请求。在这种情况下,大约 8 个并行请求(根据您的测量)似乎是合理的。
因此,很明显,如果您想在这样的场景中每秒处理 100 个请求,则需要调整所有涉及的线程池来处理此问题。您还必须微调不同的超时(CXF、Camel HTTP)。
你的代码
我在您的代码中注意到的一点是您使用Camel HTTP 组件作为目标端点。该组件使用Apache HTTP 客户端 3.x。
如果您想使用更新的Apache HTTP 客户端,则必须使用Camel HTTP4 组件(4 因为它使用 Apache HTTP 客户端 4.x)。我不知道这是否有很大的不同,但多年来旧版本被宣布为“生命终结”。
另一件事是超时。您写道您将 Camel 超时设置为 30 秒。但这可能不是 CXF 或 Apache HTTP 客户端的超时。HTTP 客户端有多个超时:建立连接可能需要很长时间,接收响应也可能需要很长时间。
| 归档时间: |
|
| 查看次数: |
438 次 |
| 最近记录: |