Well, you have just removed the intersting part : your HelloComponent
must return the response back.
This can be done by
send(ex);
If you do not do that, the client will wait for the response forever ...
Cheers,
Guillaume Nodet
Julio Faerman wrote:
Hi,
I am doing a simple InOut component to servicemix.
I want it to receive a string as a property in the inMessage and
return the same string in the outMessage.
The problem is that client.sendSync() freezes and client.send()
returns null, so i cannot get the output message.
Can anyone help me to understand what is going on ?
Code follows:
------- Component --------
public class HelloComponent extends OutBinding{
protected void process(MessageExchange ex,
NormalizedMessage inmsg) throws
MessagingException {
...
NormalizedMessage out = ex.createMessage();
out.setProperty("myString",inmsg.getProperty("myString"));
ex.setMessage(out,"out");
// canot call done(ex), as it is InOut, right ??
...
}
------- Client --------
...
InOut exchange = client.createInOutExchange();
NormalizedMessage message = exchange.getInMessage();
message.setProperty("name", "James");
message.setContent(new StreamSource(new
StringReader("<hello>world</hello>")));
// client.sendSync(exchange); /** This blocks forever **/
// client.send(exchange); /** This returns null **/
NormalizedMessage outmessage = exchange.getOutMessage();
...
------- Config --------
<!-- the JBI container -->
<sm:container spring:id="jbi" useMBeanServer="true"
createMBeanServer="true" dumpStats="true" statsInterval="10">
<sm:activationSpecs>
<!-- Route the event to a trace component that just outputs the
event to the console -->
<sm:activationSpec componentName="hello" service="my:hello">
<sm:component>
<bean xmlns="http://xbean.org/schemas/spring/1.0"
class="jm.jbi.HelloComponent"/>
</sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:container>
<bean id="client" class="org.servicemix.client.DefaultServiceMixClient">
<constructor-arg ref="jbi"/>
<constructor-arg>
<sm:activationSpec destinationService="my:hello"/>
</constructor-arg>
</bean>
What i did wrong ?
Thnx,
Julio