There's no real difference. Such thing is mandatory when using
directly the DeliveryChannel too.
If you don't, you may end up with threads locked forever or memory leaks.
With the delivery channel, you'd do:
   exchange.setStatus(ExchangeStatus.DONE);
   channel.send(exchange);
Btw, that's exactly what the client does.

On Mon, Mar 10, 2008 at 9:57 AM, Fabrice Landrodie
<[EMAIL PROTECTED]> wrote:
>
>  Thank you very much Guillaume.
>  It works well now.
>
>  I was not aware that the behaviour and the way to code message exchange is a
>  bit different when unsing ServiceMixClient object or directly the
>  DeliveryChannel object.
>
>  Regards,
>  Fabrice
>
>
>
>
>
>  gnodet wrote:
>  >
>  > I think you forgot to set and send the DONE status at the end of your
>  > processing,
>  >       MessageUtil.transferToOut(syncExchange.getMessage("out"), exchange);
>  >       channel.send(exchange);
>  >       client.done(syncExchange);
>  >
>  > On Fri, Mar 7, 2008 at 1:29 PM, Fabrice Landrodie
>  > <[EMAIL PROTECTED]> wrote:
>  >>
>  >>  Hello,
>  >>
>  >>  I am facing some memoryleak problems when using MessageExchange and
>  >>  servicemix-bean.
>  >>
>  >>  My use case is as followed :
>  >>
>  >>  http client --> BC Http Su --> smx-bean Su --> smx-bean Su
>  >>
>  >>  The request send by http client is routed to the first smx-bean Su. In
>  >>  onMessageExchange() function, I create a new MessageExchange that I sent
>  >> to
>  >>  the second smx-bean Su using sendSync() in InOut mep. The answer is the
>  >>  placed into the Out of the first Exchange and send back to the BC http.
>  >>
>  >>  It works well but the problem is that if I send a lot of request, memory
>  >>  increases but never decrease at the end of the treatment. If I set a big
>  >>  size for the xml body of the request, the memory increases faster and an
>  >>  OutOfMemory exception is raised. So it seems the memory leak is relative
>  >> to
>  >>  the size of the message.
>  >>
>  >>  I think it could be a problem of MessageExchance that are never
>  >> dereferenced
>  >>  so that the garbage collector does not free them.
>  >>
>  >>  I use a profiler to try to analyze where the memory is leak, and it
>  >> seems
>  >>  this is in a lot of int[] and char[] objects ....
>  >>
>  >>
>  >>  Can someone help me on this problem ? Maybe, I do not code the good way
>  >> for
>  >>  sending message from a bean to another one.
>  >>
>  >>  Thank you for your help,
>  >>  Fabrice
>  >>
>  >>
>  >> 
> --------------------------------------------------------------------------------------
>  >>  Here is the code of the first smx-bean SU with the onMessageExchange :
>  >>
>  >>  public class MyBean implements MessageExchangeListener {
>  >>
>  >>         private static ServiceMixClient client = null;
>  >>
>  >>         @Resource
>  >>         private DeliveryChannel channel;
>  >>         @Resource
>  >>         private ComponentContext context;
>  >>
>  >>         public void onMessageExchange (MessageExchange exchange ) throws
>  >>  MessagingException {
>  >>
>  >>                 if ( client == null ) {
>  >>                         client = new ServiceMixClientFacade(context);
>  >>                 }
>  >>
>  >>                 if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
>  >>
>  >>                         if (exchange instanceof InOut == true) {
>  >>
>  >>                                 Destination destination;
>  >>                                 destination
>  >>
>  >> 
> client.createDestination("endpoint:http://myNameSpace/MyService/MyEndpoint";);
>  >>                                 // Create New MessageExchange
>  >>                                 InOut syncExchange =
>  >> destination.createInOutExchange();
>  >>                                 QName qOperation = new QName("myOp");
>  >>                                 exchange.setOperation(qOperation);
>  >>
>  >>                                 // Get object of In Message
>  >>                                 NormalizedMessage request =
>  >> syncExchange.getInMessage();
>  >>                                 // Set the content of new In exchange
>  >> with
>  >>  th In coming from our caller
>  >>
>  >> request.setContent(exchange.getMessage("in").getContent());
>  >>
>  >>                                 // Send the new exchange and wait for the
>  >>  anwer
>  >>                                 client.sendSync(syncExchange);
>  >>
>  >>                                 // Set the out of the syncExchange into
>  >> the
>  >>  out of the current exchange and send back the current exchange
>  >>
>  >> MessageUtil.transferToOut(syncExchange.getMessage("out"), exchange);
>  >>                                 channel.send(exchange);
>  >>
>  >>                         }
>  >>         }
>  >>  }
>  >>  --
>  >>  View this message in context:
>  >> 
> http://www.nabble.com/Servicemix-bean-MemoryLeak-tp15891209s12049p15891209.html
>  >>  Sent from the ServiceMix - User mailing list archive at Nabble.com.
>  >>
>  >>
>  >
>  >
>  >
>  > --
>  > Cheers,
>  > Guillaume Nodet
>  > ------------------------
>  > Blog: http://gnodet.blogspot.com/
>  >
>  >
>
>  --
>  View this message in context: 
> http://www.nabble.com/Servicemix-bean-MemoryLeak-tp15891209s12049p15950613.html
>
>
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

Reply via email to