camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hiram Chirino" <hi...@hiramchirino.com>
Subject Re: a few comments on SedaComponent
Date Mon, 08 Oct 2007 13:47:32 GMT
On 10/7/07, William Tam <email.wtam@gmail.com> wrote:
> > >
> > > BTW, I think if the callback passes me the processed exchange, there
> > > would be super nice.  I probably care more about out message (if any)
> > > than whether it has been done synchronously or not.
> > >
> >
> > Since the caller of the asyc process call passes in the exchange, he
> > can pass that same exchange to the call back via either injection or
> > via final local reference.  Something like:
> >
> > final Exchange exch = ...
> > processor.process(exch, new AsyncCallback() {
> >   public void done(boolean sync) {
> >      System.out.println( exch.getOut() );
> >   }
> > });
> >
>
> Actually, this technique does not work for any component producer that
> makes a copy of the exchange.  For example, the seda producer makes a
> copy of an exchange and endqueue the copy.
>
>         public boolean process(Exchange exchange, AsyncCallback callback) {
>             queue.add(exchange.copy());
>             callback.done(true);
>             return true;
>         }
>
> Then, the seda consumer thread could update (in, out, fault) messages
> in the copied exchange but any update can not be seen in the orginal
> exchange (as in your example).
>

That's the point.   The copy is considered a brand new exchange that
has nothing to do with the original.  This is another reason that I
don't want to pass the exchange to the done() method.  Right now it's
simple and understood that when done() gets called the exchange that
was passed to process was the one that was completed.  If we allowed
the exchange to be passed a parameter to done then it would be
possible to create an error condition by passing the wrong exchange to
the done method.  Having implemented several async processors, just
keeping track the sync parameter is task on it own.



-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Mime
View raw message