camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: UnitOfWork ends too soon with Seda endpoints
Date Thu, 09 Apr 2009 09:07:39 GMT
Hi Jens

Thanks for reporting this. I have looked into it.

Yes the seda is async by nature and should not spin off a copy of the
exchange that shares the same unit of work as the original.
I have a fix at hand and will commit it later today.

BTW The same issue applies for the wire tap. It should also be a new
copy not sharing the same unit of work.

I will create a ticket so we have it on record.


On Wed, Apr 8, 2009 at 3:21 PM, _Jens <jens.riemschneider@icw.de> wrote:
>
> Hi,
>
> I ran into a problem with a route that called a seda endpoint. For some
> reason the unit of work within the seda route was completed before the
> actual route processing finished. Here's a simplified test case:
>
> public class SedaUnitOfWorkTest {
>    private String lastOne;
>
>    @Test
>    public void testSeda() throws Exception {
>        CamelContext context = new DefaultCamelContext();
>        context.addRoutes(new RouteBuilder() {
>            @Override
>            public void configure() throws Exception {
>                from("direct:start")
>                    .to("seda:foo")
>                    .delayer(2000);
>
>                from("seda:foo")
>                    .process(new Processor() {
>                        @Override
>                        public void process(Exchange exchange) throws
> Exception {
>                            exchange.getUnitOfWork().addSynchronization(new
> Synchronization() {
>                                @Override
>                                public void onComplete(Exchange exchange)
{
>                                    lastOne = "UnitOfWork";
>                                }
>
>                                @Override
>                                public void onFailure(Exchange exchange)
{
>                                    lastOne = "UnitOfWork";
>                                }
>                            });
>                        }
>                    })
>                    .delayer(4000)
>                    .process(new Processor() {
>                        @Override
>                        public void process(Exchange exchange) throws
> Exception {
>                            lastOne = "Processor";
>                        }
>                    });
>            }
>        });
>
>        context.start();
>        context.createProducerTemplate().send("direct:start", new
> DefaultExchange(context));
>
>        Thread.sleep(7000);
>
>        assertEquals("UnitOfWork", lastOne);
>    }
> }
>
> I'm expecting that the unit of work is the last thing that sets the field
> 'lastOne'. But it isn't, the processor is called after the unit of work
> finished.
>
> What happens is that the exchange within the Seda route does not have its
> own UnitOfWork, it is using that of the other route. This might be ok if the
> processing of the second route would be synchronous. But as it is not, I
> would expect that the second route either has its own unit of work or
> onComplete is only called if both routes have finished processing the
> exchange. Or am I wrong?
>
> Thanks,
> Jens
>
> --
> View this message in context: http://www.nabble.com/UnitOfWork-ends-too-soon-with-Seda-endpoints-tp22950359p22950359.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration

Mime
View raw message