我对mule RMItransports
有疑问这是Example_RMITest.xml
<spring:bean id="jndiFactory" name="jndiFactory" class="org.mule.transport.rmi.MuleRMIFactory"/>
<spring:bean id="jndiContext" name="jndiContext" factory-bean="jndiFactory" factory-method="create">
<spring:constructor-arg><spring:null /></spring:constructor-arg>
</spring:bean>
<rmi:connector name="rmi" jndiContext-ref="jndiContext" />
<endpoint name="Sender2" address="rmi://192.168.0.4:1111/mytask?method=say"
exchange-pattern="request-response"/>
<flow name="TestUMO">
<inbound-endpoint address="vm://query" exchange-pattern="request-response"/>
<outbound-endpoint ref="Sender"/>
</flow>
这是我的Cilent计划:
import java.util.HashMap;
import java.util.Map;
import org.mule.api.MuleContext;
import org.mule.api.MuleException;
import org.mule.api.MuleMessage;
import org.mule.context.DefaultMuleContextFactory;
import org.mule.module.client.MuleClient;
public class MyMuleClientTest {
public static void main(String[] args) throws MuleException
{
// create mule
MuleContext muleContext;
String config = "Example_RMITest.xml";
muleContext = new DefaultMuleContextFactory().createMuleContext(config);
muleContext.start();
// creat mule client
MuleClient client = new MuleClient(true);
//Map map = new HashMap();
// map.put("firstName", "p001");
MuleMessage response = client.send("vm://query", null, null);
System.out.println("response = " + response.getPayload());
}
}
例外是:
There is no receiver registered on connector "connector.VM.mule.default" for endpointUri vm://query
答案 0 :(得分:3)
您遇到的这个问题与RMI无关:Mule无法找到vm://query
端点,因为使用:
MuleClient client = new MuleClient(true);
您正在启动第二个Mule,没有任何配置,因此无法找到VM端点。
改为使用:
MuleClient client = muleContext.getClient();
让客户端连接到正在运行的Mule。