My bad, i had not noticed in the previous mails that you were using a clustered flow.
I'll check this asap.

Guillaume

Craig Walls wrote:

There's not much in my application at all...in fact, what follows is
everything I have...

My service is defined as follows:

---------------------------------
package com.habuma.sm;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import org.servicemix.MessageExchangeListener;
import org.servicemix.components.util.ComponentSupport;
import org.servicemix.jbi.jaxp.StringSource;

public class PingService extends ComponentSupport
   implements MessageExchangeListener {

 public void onMessageExchange(MessageExchange exchange)
     throws MessagingException {
     System.out.println("GOT A MESSAGE; exchange.status=" +
exchange.getStatus());
   NormalizedMessage out = exchange.createMessage();
   out.setContent(new StringSource("<response>Ping back at
ya!</response>"));
   System.out.println("SENDING RESPONSE; exchange.status=" +
exchange.getStatus());
   answer(exchange, out);
   System.out.println("RESPONSE SENT; exchange.status=" +
exchange.getStatus());
 }
}
---------------------------------

This service is configured in service-container.xml as follows:

---------------------------------
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://xbean.org/schemas/spring/1.0";
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
           xmlns:sm="http://servicemix.org/config/1.0";
           xmlns:foo="http://www.habuma.com/foo";
           xsi:schemaLocation="http://xbean.org/schemas/spring/1.0
conf/spring-beans.xsd
                               http://servicemix.org/config/1.0
conf/servicemix.xsd">

 <sm:container id="service"
     flowName="cluster">
   <sm:activationSpecs>
     <sm:activationSpec componentName="pingService"
service="foo:pingService">
       <sm:component>
         <bean class="com.habuma.sm.PingService"/>
       </sm:component>
     </sm:activationSpec>
   </sm:activationSpecs>
 </sm:container>
</beans>
---------------------------------

And the service container is started like this:

---------------------------------
package com.habuma.sm;

import org.xbean.spring.context.ClassPathXmlApplicationContext;

public class ServiceRunner {
 public static void main(String[] args) throws Exception {
   new
ClassPathXmlApplicationContext("com/habuma/sm/service-container.xml");

   Object lock = new Object();
   synchronized(lock) {
       lock.wait();
   }
 }
}
---------------------------------



On the client side, I have a simple main method that looks like this:

---------------------------------
package com.habuma.sm;

import javax.jbi.messaging.InOut;
import javax.jbi.messaging.NormalizedMessage;
import javax.xml.namespace.QName;

import org.servicemix.client.ServiceMixClient;
import org.servicemix.jbi.jaxp.StringSource;
import org.springframework.context.ApplicationContext;
import org.xbean.spring.context.ClassPathXmlApplicationContext;

public class PingClient {
 public static void main(String[] args) throws Exception {
   ApplicationContext ctx =
       new
ClassPathXmlApplicationContext("com/habuma/sm/client-container.xml");

   Thread.sleep(5000); // give the container adequate time to warm up

   ServiceMixClient client = (ServiceMixClient) ctx.getBean("client");

   InOut exchange = client.createInOutExchange();
   exchange.setService(new QName("http://www.habuma.com/foo";,
"pingService"));
   NormalizedMessage in = exchange.getInMessage();
   in.setContent(new StringSource("<ping>Pinging you</ping>"));
   System.out.println("SENDING; exchange.status=" + exchange.getStatus());
   client.sendSync(exchange);
   System.out.println("GOT RESPONSE; exchange.status=" +
exchange.getStatus());
   client.done(exchange);
 }
}
---------------------------------


And the client-side container is configured in client-container.xml like
this:

---------------------------------
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://xbean.org/schemas/spring/1.0";
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
           xmlns:sm="http://servicemix.org/config/1.0";
           xsi:schemaLocation="http://xbean.org/schemas/spring/1.0
conf/spring-beans.xsd
                               http://servicemix.org/config/1.0
conf/servicemix.xsd">

 <sm:container id="jbi"
     flowName="cluster"
     name="jbi"/>

 <bean id="client"
     class="org.servicemix.client.DefaultServiceMixClient">
   <constructor-arg ref="jbi" />
 </bean>
</beans>
---------------------------------

That is the entirety of my application's code. My classpath includes
everything in ServiceMix 2.0.1's lib directory (except that I swapped out
xercesImpl-2.7.1.jar for xercesImpl-2.6.2.jar), servicemix-2.0.1.jar, and
activecluster-1.1-SNAPSHOT.jar from the optional directory.

When I run this, I first run ServiceRunner to start up the container, then
I  run PingClient.

PingClient's output is:
 SENDING; exchange.status=Active

And ServiceRunner's output is:
 GOT A MESSAGE; exchange.status=Active
 SENDING RESPONSE; exchange.status=Active
 RESPONSE SENT; exchange.status=Active

The client.sendSync() method never returns. I'm not saying that this is a
bug in ServiceMix. But if it's not, then what am I doing wrong?







Most of our unit tests use the servicemix client for sending messages,
and lots of them in a synchronous way.  So there must be something in
your application that causes this behavior.
Could you provide a simple test case / main so that i can check this ?

Cheers,
Guillaume Nodet

Craig Walls wrote:

I have a client that sends a message like this:

InOut exchange = serviceMixClient.createInOutExchange();
NormalizedMessage message = exchange.getInMessage();
exchange.setService(new QName("myService"));
message.setProperty("someProperty", "someValue");
message.setContent(new StringSource("<question>How are
you?</question>")); serviceMixClient.sendSync(exchange);
NormalizedMessage result = exchange.getOutMessage();

On the service-side, my onMessageExchange() method looks a little
something like this:

public void onMessageExchange(MessageExchange exchange) throws
MessagingException {

NormalizedMessage out = exchange.createMessage();
out.setContent(new StringSource("<answer>I am fine</answer>"));
message.setMessage(out, "out");   // PAY ATTENTION
done(exchange);                   // TO THESE LINES
}

In ServiceMix 1.1, this worked fine. But since moving to ServiceMix
2.0, I get an error indicating that I can't set the status to done.
Fine, so I swapped out the commented lines above with:

message.setMessage(out, "out");
send(exchange);

Now my sendSync() never returns. On a hunch, I tried this instead:

answer(exchange, out);

Same effect. onMessageExchange() method completes on the service-side,
but on the client-side, the sendSync() method never returns.

I'm certain that it's something that I'm doing wrong, but I'm not sure
what. Anybody see the problem? Please help!













Reply via email to