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.

>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?

Reply via email to