你爲什麼不使用騾標準輸入輸出IN組件採取騾子工作室輸入...例如: - 在騾子流量: -
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio" xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="EE-3.4.2" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<stdio:connector name="stdio" messageDelayTime="1000" promptMessage="Enter a parameter :" doc:name="STDIO" validateConnections="true"></stdio:connector>
<flow name="InputFlow" doc:name="InputFlow">
<stdio:inbound-endpoint system="IN" responseTimeout="10000" connector-ref="stdio" doc:name="STDIO"></stdio:inbound-endpoint>
<custom-transformer class="InputProccesser" doc:name="Java"/>
<logger message="Payload is :- #[message.payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
現在,我們已經在InputProccesser是java類將處理流程中使用<custom-transformer class="InputProccesser" doc:name="Java"/>
輸入消息...
現在,你創建一個名爲InputProccesser一個Java類: -
import java.util.List;
import java.util.Map;
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractMessageTransformer;
public class InputProccesser extends AbstractMessageTransformer {
@Override
public Object transformMessage(MuleMessage message, String outputEncoding)
throws TransformerException {
String mes=(String) message.getPayload();
int input=0;
try
{
input = Integer.parseInt(mes);
System.out.println(" Your input variable is "+input);
return input;
}
catch(NumberFormatException nFE)
{
System.out.println("Please enter a number");
return input;
}
}
}
現在你可以修改java類按您的要求來處理輸入信息並能使用Mule stdio組件用於在運行mule應用程序後進行輸入
這看起來像[此問題]的副本(http://stackoverflow.com/questions/14769142/how-to-invoke-a-java-組件在-騾) –