camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Birkland <bir...@gmail.com>
Subject Context Component issue
Date Tue, 25 Aug 2015 18:45:28 GMT
Hello,

I'm having a strange problem with the camel context component and think it
may be a bug.   I've created a unit test that currently fails:

https://gist.github.com/birkland/1b12261521dd5d5c79ef

Basically, I'm trying create a 'parent' camel context that routes a message
through two 'black box' camel contexts (named bb1 and bb2); each one
containing arbitrary routes, but containing local endpoints direct:in and
direct:out.  The presence of these endpoints is a kind of "api" to a given
black box.

In the test above, the parent context is trying to pass a message through
two black boxes by wiring them together, with routes like:

from("direct:start").to(bb1:in);
from(bb1:out).to(bb2:in);
from(bb2:out).to("mock:end");

The problem is the test fails due to an exception:
org.apache.camel.FailedToStartRouteException: Failed to start route route5
because of Multiple consumers for the same endpoint is not allowed:
Endpoint[direct://out]
at
org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:3142)
...

This is with camel 2.15.2

Tracing the failure, I see that endpoints are analyzed in:
doCheckMultipleConsumerSupportClash(Endpoint endpoint, List<Endpoint>
routeInputs)

The problem is at line 3205 of DefaultCamelContext.java:
if (routeInputs.contains(endpoint)) { return false; }

It's not comparing endpoints by their logical name in the parent context
(bb1:out, bb2:out), but instead by their local names/URIs (direct:out,
drect:out).  Each of these endpoints is an instance of DefaultEndpoint.  In
the equals() method, they are considered equivalent if their URIs match.

So to me, it looks like the logic for detecting 'the same endpoint' for the
purpose of assuring that a single endpoint doesn't have multiple consumers
is incorrect in the case where endpoints defined in different camel
contexts are being compared.  Identically named endpoints in separate
"black box" contexts are being considered to be equivalent, which they
clearly aren't.

Does this look like a bug to anybody else?  Could a simple solution be in
DefaultEndpoint#equals:  compare equivalence of endpoint URIs *and*
containing camel context IDs, rather than just URI alone?

Thanks,
   -Aaron

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message