« Return to Thread: Re: LoanBroker ESB test failing...

Re: Re: LoanBroker ESB test failing...

by Holger Hoffstätte-2 :: Rate this Message:

Reply to Author | View in Thread

ARGCRP-CARLSON, TRAVIS wrote:
> 3. There is a race condition which causes the unit test to _sometimes_
> fail.
>
> #1 and #2 were fixed outright.
>
> As a workaround for #3, I added a minimal log4j.properties to the
> loanbroker-esb and this makes the test pass, at least in my environment.

I assume you know this but that's not a workaround since it "may" simply
fail differently on different machines, so we might as well make it
official and keep it as reminder. Steph's greenmail extensions worked
great as well until I removed all logging..

How does this race manifest itself? I suspect that it is in fact not a
race in the traditional sense but simply yet another symptom of multiple
threads using the same receiver/dispatcher at the same time, which is just
a consequence of the way they are currently managed; see
http://jira.symphonysoft.com/browse/MULE-966 and
AbstractConnector.getDispatcher(UMOImmutableEndpoint) and similarly for
getReceiver(UMOComponent, UMOEndpoint). A simple "fix" would be to have a
KeyedObjectPool that manages things by endpoint key and only hands out a
new dispatcher/receiver when the old one has been returned. I do not know
(suspect) if this is a good idea since it means that only one request or
dispatch for a given connector's endpoint can run at the same time. One
other alternative approach would be to keep the currently used
ConcurrentMap + synchronized retrieval on endpoint (which is an
appropriate design, scales nicely and has minimal overhead) and simply put
a pool into the map, so that each endpoint key maps to several
receivers/dispatchers "standing in line".
The existing Dispatcher/Receiver factory could be wrapped as PoolFactory
which would take care of lifecycle control like
handout/return/creation/cleanup.

Unfortunately the current commons-pool StackedObjectPool implementation is
less than efficient in many ways, but that's a topic for another day..

> For a definite solution, I guess I'll have to finish reading the JCIP
> book. :-(

Do that, and have a cup of tea:
http://www.rider.edu/~suler/zenstory/teacombat.html

:-)
Holger

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

 « Return to Thread: Re: LoanBroker ESB test failing...