我通过使用单例实例在 WebserviceTestImpl 类的 test() 方法中存储 requestMessage 并在 TestSubflow 组件中检索它来解决这个问题。我不确定它是否完美。但它有效:)
这是我的做法。。
骡子配置:
<flow name="webserviceTestFlow">
<http:inbound-endpoint address="${webservicetest.env.endpoint}" exchange-pattern="request-response" doc:name="HTTP"/>
<cxf:simple-service serviceClass="com.test.WebserviceTest" doc:name="SOAP"/>
<component class="com.test.WebserviceTestImpl" />
<flow-ref name="testSubflow"/>
</flow>
<sub-flow name="testSubflow">
<pooled-component class="com.test.TestSubflow">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_FAIL" initialisationPolicy="INITIALISE_ALL" maxActive="1" maxIdle="2" maxWait="3" />
</pooled-component>
</sub-flow>
WebserviceTestImpl 和 TestSubflow 代码片段
public class WebserviceTestImpl implements WebserviceTest,Serializable {
private static final long serialVersionUID = 1L;
private TestMessageProxy testMessageProxy;
public TriggerTestImpl() {
this.testMessageProxy = TestMessageProxy.getInstance();
}
@Override
public String test(String requestMessage) throws Exception{
this.testMessageProxy.setTestMessage(requestMessage);
return "success";
}
}
public class TestSubflow implements Callable{
private TestMessageProxy testMessageProxy;
public TestSubflow() {
this.testMessageProxy = TestMessageProxy.getInstance();
}
@Override
public Object onCall(MuleEventContext context) throws Exception {
String testMessage = this.testMessageProxy.getTestMessage();
}
}