我是Mule的新手,我正在研究一个问题,这个问题需要一个流程,将消息转发到Mule消息总线,监听器可以接收这些消息,以便在工作完成后接收成功处理这些消息的通知。主要标准是“调度程序流程”不会被阻止继续执行其工作(将其他不同的消息放在总线上以供潜在的其他听众使用)。
我有一个测试应用程序,我一直在MuleStudio(下面)中运行,它包含了我想要实现的基础知识,简化了;这是一个非常简单的2流程应用程序,使用request-reply允许第二个流程将回复发送回主流程;这里的主要问题是主流的线程被阻塞,阻止它做任何事情,直到响应回来。有没有办法让响应回到主流的不同主题上,或者是否有其他方法可以根据标准完成此操作?
感谢您提供任何帮助或指示; - )
...
<!-- simple Groovy transformer that changes the msg payload to a greeting w/ the current time-->
<scripting:transformer name="toCurrentTime">
<scripting:script engine="groovy">
import java.text.SimpleDateFormat;
def DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";
def cal = Calendar.getInstance();
def sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
return "Response @ time " + sdf.format(cal.getTime())
</scripting:script>
</scripting:transformer>
<!--
note : neither of the following are allowed on the flow b/c of the request-reply
processingStrategy="synchronous"
processingStrategy="queued-asynchronous"
-->
<flow name="main" doc:name="main">
<http:inbound-endpoint ref="httpEventInjector" doc:name="HTTP"/>
<logger message="starting main flow" level="INFO"/>
<request-reply storePrefix="mainFlow">
<vm:outbound-endpoint path="worker"></vm:outbound-endpoint>
<vm:inbound-endpoint path="reply"></vm:inbound-endpoint>
</request-reply>
<!-- processing continues once we get the response on the 'reply' channel above from the worker -->
<!-- generate the response for the browser -->
<logger message="finishing main flow w/ browser response" level="INFO"/>
<response>
<transformer ref="toCurrentTime"/>
</response>
</flow>
<flow name="worker" doc:name="worker">
<vm:inbound-endpoint path="worker"/>
<logger message="starting worker task(s) ...." level="INFO"/>
<scripting:component doc:name="thread-sleep(10s)">
<scripting:script engine="Groovy">
System.out.println "about to sleep @ time" + System.currentTimeMillis()
Thread.sleep(10000);
System.out.println "done sleeping @ time" + System.currentTimeMillis()
</scripting:script>
</scripting:component>
<logger message="finishing up worker task(s) ...." level="INFO"/>
</flow>