Java 从mule esb向主程序传递参数

Java 从mule esb向主程序传递参数,java,groovy,mule,jython,Java,Groovy,Mule,Jython,我有一个简单的java程序,要执行main方法。执行时,我需要传递一些参数,如下所示: class Main{ public static void main(String[] args) { initializeBaseClass(); } 以以下方式运行上述程序: java -classpath C;/test/sample.jar -mainClass com.test.SampleTest 它执行并成功运行 现在我需要从Mule esb运行相同的程序。 哪种方

我有一个简单的java程序,要执行main方法。执行时,我需要传递一些参数,如下所示:

class Main{
    public static void main(String[] args) {
        initializeBaseClass();
}
以以下方式运行上述程序:

java -classpath C;/test/sample.jar -mainClass com.test.SampleTest
它执行并成功运行

现在我需要从Mule esb运行相同的程序。 哪种方法是调用此方法并从mule esb执行的最佳方法

我尝试过添加java组件和添加属性键/值,但没有效果。如何从mule传递参数?
使用Spring、脚本语言或MEL有更好的方法吗?

为什么不在组件中使用Mulestdio在Mule studio中获取输入。。。例如:-在骡流中:-

    <spring:beans>
        <spring:bean id="transmission" class="com.test.InvokeMain"/>
    </spring:beans>
    <flow name="test" ...
       <set-payload value="-mainclass com.test.Abcd -driver org.hsqldb.jdbc.JDBCDriver/>
       <invoke object-ref="transmission" method="invoke" methodArgumentTypes="java.lang.String" methodArguments="#[payload]" name="transmissionAPI"/>
    </flow>
<?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>

现在,您可以根据需要修改java类以处理输入消息,并可以在运行Mule应用程序后使用Mule stdio组件获取输入

这看起来像
<?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>
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;
         }


   }

}