使用下面的 Mule 配置和 Java 代码,我无法让 Mule 通过组件绑定传播异常。如何让远程服务上抛出的异常传播到调用组件?骡 EE 3.2.2
谢谢
骡子配置
<mule ...>
<flow name="Test">
<vm:inbound-endpoint path="Test" exchange-pattern="request-response" />
<component class="foo.Component">
<binding interface="foo.Interface" method="bar">
<vm:outbound-endpoint path="Interface.bar"
exchange-pattern="request-response" />
</binding>
</component>
</flow>
<flow name="Interface.bar">
<vm:inbound-endpoint path="Interface.bar"
exchange-pattern="request-response" />
<scripting:component>
<scripting:script engine="groovy">
throw new Exception();
</scripting:script>
</scripting:component>
</flow>
</mule>
Java 代码
组件.java
package foo;
public class Component {
private Interface theInterface;
public void foo(final String unused) throws Exception {
theInterface.bar();
}
public void set(final Interface anInterface) {
theInterface = anInterface;
}
}
接口.java
package foo;
public interface Interface {
String bar() throws Exception;
}
司机
package foo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import org.mule.api.MuleException;
import org.mule.api.client.MuleClient;
import org.mule.tck.junit4.FunctionalTestCase;
@RunWith(MockitoJUnitRunner.class)
public class ATest extends FunctionalTestCase {
@Test(expected = Exception.class)
public void willItThrowException() throws MuleException {
final MuleClient client = muleContext.getClient();
client.send("vm://Test", "", null, RECEIVE_TIMEOUT);
}
@Override
protected String getConfigResources() {
return "app/mule-config.xml";
}
}