1

我有一个关于 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
4

1 回答 1

3

您遇到的这个问题与 RMI 无关:Mule 找不到vm://query端点,因为通过使用:

MuleClient client = new MuleClient(true);

您正在启动第二个 Mule,没有任何配置,因此无法找到 VM 端点。

而是使用:

MuleClient client = muleContext.getClient();

让客户端连接到正在运行的 Mule。

于 2013-08-26T14:14:50.420 回答