the configuration file:
<service name="Square">
<inbound>
<vm:inbound-endpoint path="math" />
</inbound>
<component class="shou.mule.Square"/>
<outbound>
<pass-through-router>
<vm:outbound-endpoint path="inverse" />
</pass-through-router>
</outbound>
</service>
<service name="Inverse">
<inbound>
<vm:inbound-endpoint path="inverse" />
</inbound>
<component class="shou.mule.Inverse"/>
</service>
the test client :MuleClient1.java
package shou.mule;
import org.mule.api.MuleException;
import org.mule.api.MuleMessage;
import org.mule.module.client.MuleClient;
public class ClientTest1 {
public static void main(String[] args){
MuleClient client = null;
try {
client = new MuleClient();
String url = "vm://math";
MuleMessage message = client.send(url,5,null);
Integer obj = (Integer) message.getPayload();
System.out.println(obj.intValue());
} catch (MuleException e) {
e.printStackTrace();
}finally{
client.dispose();
}
}
}
the two java component :
Square.java:
package shou.mule;
public class Square {
private int payload=0;
public int square(int num) {
payload=num*num;
return payload;
}
}
Inverse.java:
package shou.mule;
public class Inverse {
private int iresult=0;
public int inverse(int num) {
iresult=num*(-1);
return iresult;
}
}
when i tested this example,it always reported this errors:
org.mule.api.transport.DispatchException: Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=vm://math, connector=VMConnector{this=12a3793, started=true, initialised=true, name='connector.VM.0', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=true, supportedProtocols=[vm], serviceOverrides=null}, transformer=[], name='endpoint.vm.math', properties={}, transactionConfig=Transaction{factory=null, action=NEVER, timeout=0}, filter=null, deleteUnacceptedMessages=false, securityFilter=null, synchronous=false, initialState=started, remoteSync=false, remoteSyncTimeout=10000, endpointEncoding=UTF-8}. Message payload is of type: Integer
at org.mule.transport.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:195)
at org.mule.transport.AbstractConnector.send(AbstractConnector.java:1929)
at org.mule.endpoint.DefaultOutboundEndpoint.send(DefaultOutboundEndpoint.java:77)
at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:327)
at org.mule.module.client.MuleClient.send(MuleClient.java:650)
at org.mule.module.client.MuleClient.send(MuleClient.java:627)
at org.mule.module.client.MuleClient.send(MuleClient.java:580)
at shou.mule.ClientTest1.main(ClientTest1.java:14)
Caused by: org.mule.api.transport.NoReceiverForEndpointException: There is no receiver registered on connector "connector.VM.0" for endpointUri vm://math
at org.mule.transport.vm.VMMessageDispatcher.doSend(VMMessageDispatcher.java:109)
at org.mule.transport.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:168)
... 7 more
would you give me some answers,thank you again.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
you're using async endpoints, I'm not sure if that's what you want. Try
making all endpoints sync.
-dirk
maybe there is something wrong with the the java component Square.java and Inverse.java.
else :it also reported errors:
2010-1-19 15:09:59 org.apache.cxf.bus.spring.BusApplicationContext getConfigResources
信息: No cxf.xml configuration file detected, relying on defaults.
Exception in thread "main" java.lang.ClassCastException: org.mule.transport.NullPayload cannot be cast to java.lang.Integer
at shou.mule.ClientTest1.main(ClientTest1.java:15)
thank you again.
-Fang
I'm glad it helped :-)
> i don"t understand the meaning of " why making your components statefull?"
> *can you give me an example.*
Have a look at one of your classes:
public class Square {
private int payload=0;
public int square(int num) {
payload=num*num;
return payload;
}
}
it has an instance variable "payload" that holds the result of the
computation. Why would you hold on to that state? The square() method
should just return the result of the calculation.
-dirk
Exception in thread "main" java.lang.ClassCastException: org.mule.transport.NullPayload cannot be cast to java.lang.Integer
at shou.mule.ClientTest1.main(ClientTest1.java:15)