[servicemix-user] sendSync and SM 2.0

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[servicemix-user] sendSync and SM 2.0

Craig Walls

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 | Threaded
Open this post in threaded view
|

RE: [servicemix-user] sendSync and SM 2.0

Metta
Craig - I am experiencing similar issues with setting status to DONE in
SM2.0... the code surrounding this area is quite hard to read so I
haven't worked out what is going on yet.. for some reason DONE is not in
the list of allowed statuses...



> -----Original Message-----
> From: Craig Walls [mailto:[hidden email]]
> Sent: 10 November 2005 19:12
> To: [hidden email]
> Subject: [servicemix-user] sendSync and SM 2.0
>
>
> 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!
>
>
>
>




This message has been scanned for viruses.
Reply | Threaded
Open this post in threaded view
|

Re: [servicemix-user] sendSync and SM 2.0

Guillaume Nodet-3
ServiceMix 2 now enforces correct use of message exchanges.
You can refer to the jbi spec on pages 31 to 33 to have diagrams about the
different state of an exchange.

Following is a description of the in-only and in-out diagrams, when the
exchange succeeds.
Note that the exchange can also be set to an ERROR status, but in all
cases, it ends with
a DONE state, without any other informations conveyed : you can not set
the answer or
an error and the DONE state at the same time.

In-Only
   o the consumer send the message in a ACTIVE state
   o the provider receives the message and send it back with a DONE state

In-Out
   o the consumer send the message in an ACTIVE state
   o the provider receives the message, fill the response and send the
exchange back with an ACTIVE state
   o the consumer receives the exchange, set the status to DONE and send it.

Cheers,
Guillaume Nodet

Matthew Clark wrote:

>Craig - I am experiencing similar issues with setting status to DONE in
>SM2.0... the code surrounding this area is quite hard to read so I
>haven't worked out what is going on yet.. for some reason DONE is not in
>the list of allowed statuses...
>
>
>
>  
>
>>-----Original Message-----
>>From: Craig Walls [mailto:[hidden email]]
>>Sent: 10 November 2005 19:12
>>To: [hidden email]
>>Subject: [servicemix-user] sendSync and SM 2.0
>>
>>
>>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!
>>
>>
>>
>>
>>    
>>
>
>
>
>
>This message has been scanned for viruses.
>
>
>  
>

Reply | Threaded
Open this post in threaded view
|

Re: [servicemix-user] sendSync and SM 2.0

Guillaume Nodet-3
In reply to this post by Craig Walls
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 | Threaded
Open this post in threaded view
|

Re: [servicemix-user] sendSync and SM 2.0

Craig Walls

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 | Threaded
Open this post in threaded view
|

Re: [servicemix-user] sendSync and SM 2.0

Guillaume Nodet-3
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 | Threaded
Open this post in threaded view
|

RE: [servicemix-user] sendSync and SM 2.0

Metta
In reply to this post by Craig Walls
So if the Service Consumer does not require a response, it is OK to
never set the status to DONE?  



> -----Original Message-----
> From: Guillaume Nodet [mailto:[hidden email]]
> Sent: 10 November 2005 20:19
> To: [hidden email]
> Subject: Re: [servicemix-user] sendSync and SM 2.0
>
> ServiceMix 2 now enforces correct use of message exchanges.
> You can refer to the jbi spec on pages 31 to 33 to have diagrams about
the
> different state of an exchange.
>
> Following is a description of the in-only and in-out diagrams, when
the
> exchange succeeds.
> Note that the exchange can also be set to an ERROR status, but in all
> cases, it ends with
> a DONE state, without any other informations conveyed : you can not
set
> the answer or
> an error and the DONE state at the same time.
>
> In-Only
>    o the consumer send the message in a ACTIVE state
>    o the provider receives the message and send it back with a DONE
state
>
> In-Out
>    o the consumer send the message in an ACTIVE state
>    o the provider receives the message, fill the response and send the
> exchange back with an ACTIVE state
>    o the consumer receives the exchange, set the status to DONE and
send
> it.
>
> Cheers,
> Guillaume Nodet
>
> Matthew Clark wrote:
>
> >Craig - I am experiencing similar issues with setting status to DONE
in
> >SM2.0... the code surrounding this area is quite hard to read so I
> >haven't worked out what is going on yet.. for some reason DONE is not
in

> >the list of allowed statuses...
> >
> >
> >
> >
> >
> >>-----Original Message-----
> >>From: Craig Walls [mailto:[hidden email]]
> >>Sent: 10 November 2005 19:12
> >>To: [hidden email]
> >>Subject: [servicemix-user] sendSync and SM 2.0
> >>
> >>
> >>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!
> >>
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> >This message has been scanned for viruses.
> >
> >
> >
> >
>


Reply | Threaded
Open this post in threaded view
|

Re: [servicemix-user] sendSync and SM 2.0

Guillaume Nodet-3
Yes, unless the message was sent using a sendSync.  The sendSync will
only return when the exchange
has been received.  So even if this could work in your case, you'd
better send the DONE status back.

Cheers,
Guillaume

Matthew Clark wrote:

>So if the Service Consumer does not require a response, it is OK to
>never set the status to DONE?  
>
>
>
>  
>
>>-----Original Message-----
>>From: Guillaume Nodet [mailto:[hidden email]]
>>Sent: 10 November 2005 20:19
>>To: [hidden email]
>>Subject: Re: [servicemix-user] sendSync and SM 2.0
>>
>>ServiceMix 2 now enforces correct use of message exchanges.
>>You can refer to the jbi spec on pages 31 to 33 to have diagrams about
>>    
>>
>the
>  
>
>>different state of an exchange.
>>
>>Following is a description of the in-only and in-out diagrams, when
>>    
>>
>the
>  
>
>>exchange succeeds.
>>Note that the exchange can also be set to an ERROR status, but in all
>>cases, it ends with
>>a DONE state, without any other informations conveyed : you can not
>>    
>>
>set
>  
>
>>the answer or
>>an error and the DONE state at the same time.
>>
>>In-Only
>>   o the consumer send the message in a ACTIVE state
>>   o the provider receives the message and send it back with a DONE
>>    
>>
>state
>  
>
>>In-Out
>>   o the consumer send the message in an ACTIVE state
>>   o the provider receives the message, fill the response and send the
>>exchange back with an ACTIVE state
>>   o the consumer receives the exchange, set the status to DONE and
>>    
>>
>send
>  
>
>>it.
>>
>>Cheers,
>>Guillaume Nodet
>>
>>Matthew Clark wrote:
>>
>>    
>>
>>>Craig - I am experiencing similar issues with setting status to DONE
>>>      
>>>
>in
>  
>
>>>SM2.0... the code surrounding this area is quite hard to read so I
>>>haven't worked out what is going on yet.. for some reason DONE is not
>>>      
>>>
>in
>  
>
>>>the list of allowed statuses...
>>>
>>>
>>>
>>>
>>>
>>>      
>>>
>>>>-----Original Message-----
>>>>From: Craig Walls [mailto:[hidden email]]
>>>>Sent: 10 November 2005 19:12
>>>>To: [hidden email]
>>>>Subject: [servicemix-user] sendSync and SM 2.0
>>>>
>>>>
>>>>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!
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>
>>>
>>>This message has been scanned for viruses.
>>>
>>>
>>>
>>>
>>>      
>>>
>
>
>
>
>  
>