本文主要是介绍mule 异步方式是一种单向调用,调用者不需要获得响应。,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
异步方式通过inbound和outbound endpoint的exchange-pattern=”one-way”实现。
使用基本的Stdio Transport验证,通过标准输入传输字符串,将其原样传递给标准输出进行显示。相应配置如下:
stdio-asynchronous-single.xml
1. <?xml version="1.0" encoding="UTF-8"?>
2. <mule xmlns="http://www.mulesoft.org/schema/mule/core"
3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4. xmlns:spring="http://www.springframework.org/schema/beans"
5. xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
6. xsi:schemaLocation="
7. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
8. http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
9. http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.xsd">
10.
11. <stdio:connector name="stdioConnector"
12. messageDelayTime="1234"
13. outputMessage="abc"
14. promptMessage="bcd"
15. promptMessageCode="456"
16. />
17.
18.
19. <model name="model">
20. <service name="echo">
21. <inbound>
22. <stdio:inbound-endpoint system="IN" exchange-pattern="one-way" />
23. </inbound>
24.
25. <component>
26. <singleton-object class="com.easyway.esb.mule.stdio.StdIo" />
27. </component>
28. <outbound>
29. <pass-through-router>
30. <stdio:outbound-endpoint system="OUT" exchange-pattern="one-way" />
31. </pass-through-router>
32. </outbound>
33. </service>
34. </model>
35. </mule>
测试代码:
1. String configFile = "stdio-asynchronous-single.xml";
2. String[] configFileArr = new String[] {configFile };
3. MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
4. MuleContext muleContext = muleContextFactory.createMuleContext(new SpringXmlConfigurationBuilder(
5. configFileArr));
6. muleContext.start();
异步方式适用于简单的消息传递的场景。
这篇关于mule 异步方式是一种单向调用,调用者不需要获得响应。的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!