On 10/8/07, William Tam <[EMAIL PROTECTED]> wrote:
> On 10/8/07, Hiram Chirino <[EMAIL PROTECTED]> wrote:
> > On 10/7/07, William Tam <[EMAIL PROTECTED]> 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.
> >
>
> Suppose I call async send and just want to handle the out message in
> the exchange the processing is done.  As the sender, why do I have to
> worry about whether the endpoint implementation creates a copy of the
> exchange or not?   I don't see it can be a good thing if the code
> snippet you've given above works for some endpoints but not all
> endpoints.

Ok i agree. But the problem is we are looking at the seda example
which does NOT populate the out message.  It's an in only pattern.
For example if this was an async http component instead, then no, the
callback.done() method would not be called until the http component
populated the out message.   The point of the seda doing a copy is
that once the message it enqueued, the consumer from that queue should
not be working on exchange that could be changing behind it's back.
But I still fail to see how this is related to passing the exchange as
a parameter to the done method call.

>
> >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.
>
> We might have some misunderstanding.   The exchange that was completed
> was the copy and NOT the original, right?
>

When the seda producer enqueued the copy.. it was done with the original.

-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Reply via email to