You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Guillaume Nodet <gn...@gmail.com> on 2007/09/12 14:47:06 UTC

Re: Asynchronous Exchange Processing

I somewhat agree with that.I think it would simplify the API to have

exchange.onCommit(new Runnable() {
  public void run() {
    // do whatever
  }
};

or

exchange.onCommit(new Callback<Exchange>() {
  public void handle(Exchange exchange) {
    // do whatever
  }
};

rather than

exchange.getUnitOfWork().addSynchronization(new Synchronization() {
  public void onComplete(Exchange exchange) {
    // do whatever
  }
  public void onFailure(Exchange exchange) {
  }
});

But this is no big deal.
The main point is to have it and have the whole core to support
asynchronous
processors.  I'll try to work on that soon.

On 8/29/07, Brian McCallister <br...@skife.org> wrote:
>
> I would consider just saying exchange.on[Commit|Fail] at the user level.
>
> The reason here is that the Exchange represents... an exchange
> between endpoints. it *is* the unit of work. Implying that there is a
> separate transaction it is operating in muddies the waters.
>
> -Brian
>
> On Aug 29, 2007, at 1:12 AM, James Strachan wrote:
>
> > Incidentally as a first stab at tackling CAMEL-123
> > https://issues.apache.org/activemq/browse/CAMEL-123
> >
> > I've added a UnitOfWork object on an Exchange that can be used to
> > register onComplete/onFailure hooks when processing of a message
> > exchange has been completed. Its not yet wired into the sync/async
> > changes Hiram made though but gives an idea of what I was wondering
> > about.
> >
> > If you take a look at the DefaultUnitOfWork.addAsyncStep() - I was
> > kinda wondering if we could use the UnitOfWork object as a factory of
> > AsyncCallback objects when working with async stuff; so that by
> > default when all the async callbacks complete, the UnitOfWork's
> > Synchronization handlers could be invoked (e.g. the onComplete /
> > onFailure handlers). Then my next thought was could we move a bit more
> > of the code from the changes to Pipeline out into the UnitOfWork
> > class; still a bit embyonic my thoughts though - its complex stuff
> > this sync v async v transactions stuff :)
> >
> > --
> > James
> > -------
> > http://macstrac.blogspot.com/
>
>


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