You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by apara <ap...@standardset.com> on 2015/04/30 10:18:53 UTC
AmbiguousMethodCallException but both methods are the same!
I have a route that looks like this:
<camel:route>
<camel:from uri="direct://handle.event" />
<camel:to
uri="log:com.mediaplatform.CAMEL-IN-beforeEventLogger?level=DEBUG&showAll=true&multiline=true"
/>
<camel:to uri="direct://eventDataLogger"/>
<camel:to
uri="log:com.mediaplatform.CAMEL-IN-beforeDuplicateEventChecker?level=DEBUG&showAll=true&multiline=true"
/>
<camel:to uri="direct://duplicateEventChecker" />
<camel:to
uri="log:com.mediaplatform.CAMEL-IN-beforeDateTransform?level=DEBUG&showAll=true&multiline=true"
/>
<camel:to uri="direct://dateTransformation"/>
<camel:to uri="direct://userAgentParser" />
<camel:to uri="direct://pageToIdEventAssociation"/>
<camel:to uri="direct://bufferedEventInsertAugmentation"/>
<camel:to uri="direct://playerStartUpEventAugmentation"/>
<camel:to uri="direct://loadStartToPreviousLoadstartAssociation"
/>
<camel:to uri="direct://insertPlaySuccessAfterTimeupdate" />
<camel:to
uri="direct://bufferedEventToPreviousLoadStartAssociation" />
<camel:to uri="direct://mongoDBPersistence"/>
</camel:route>
All the endpoints are proxies to spring bean. All proxies implement the
same interface:
public interface Handler {
Future<EventData> asyncHandle(EventData data) throws HandlerException;
EventData syncHandle(EventData data) throws HandlerException;
}
When the route is invoked with syncHandle method, everything works fine.
However, when I invoke the route with asyncHandle() I see that at first, the
bodyType in the exchange if of type:
org.apache.camel.component.bean.BeanInvocation
2015-04-30 01:05:31,396 kinesis-consumer DEBUG [Camel
(handler-b7cd7848-9cc8-11e4-89d3-123b93f75cba) thread #8 -
CamelInvocationHandler] com.mediaplatform.CAMEL-IN-beforeEventLogger
[CamelLogger.java:170] Exchange[
, Id: ID-apara-i-standardset-com-65381-1430381111386-0-12
, ExchangePattern: InOut
, Properties: {CamelCreatedTimestamp=Thu Apr 30 01:05:31 PDT 2015,
CamelMessageHistory=[DefaultMessageHistory[routeId=route2, node=to2]],
CamelToEndpoint=log://com.mediaplatform.CAMEL-IN-beforeEventLogger?level=DEBUG&multiline=true&showAll=true}
, Headers:
{breadcrumbId=ID-apara-i-standardset-com-65381-1430381111386-0-10}
, BodyType: org.apache.camel.component.bean.BeanInvocation
, Body: BeanInvocation public abstract java.util.concurrent.Future
com.mediaplatform.cdc.consumer.process.handler.Handler.asyncHandle(com.mediaplatform.cdc.event.EventData)
throws
com.mediaplatform.cdc.consumer.process.handler.exception.HandlerException
with [EventDataImpl{id='null', partitionKey='constant',
vd=VariableDataImpl{} {T=pl, ts=2015-04-29T15:56:07.463Z, ua=Mozilla/5.0
(Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/41.0.2272.104 Safari/537.36,
eid=82da185c-7a55-49a3-9eb6-948fac23d0ee, av=5.0 (Macintosh; Intel Mac OS X
10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104
Safari/537.36}}]]
, Out: null:
]
So, the first end-point is invoked correctly. However, after the first
endpoint, the body type becomes:
java.util.concurrent.FutureTask
2015-04-30 01:05:31,408 kinesis-consumer DEBUG [Camel
(handler-b7cd7848-9cc8-11e4-89d3-123b93f75cba) thread #8 -
CamelInvocationHandler]
com.mediaplatform.CAMEL-IN-beforeDuplicateEventChecker
[CamelLogger.java:170] Exchange[
, Id: ID-apara-i-standardset-com-65381-1430381111386-0-12
, ExchangePattern: InOut
, Properties: {CamelCreatedTimestamp=Thu Apr 30 01:05:31 PDT 2015,
CamelMessageHistory=[DefaultMessageHistory[routeId=route2, node=to2],
DefaultMessageHistory[routeId=route2, node=to3],
DefaultMessageHistory[routeId=route2, node=to4]],
CamelToEndpoint=log://com.mediaplatform.CAMEL-IN-beforeDuplicateEventChecker?level=DEBUG&multiline=true&showAll=true}
, Headers:
{breadcrumbId=ID-apara-i-standardset-com-65381-1430381111386-0-10}
, BodyType: java.util.concurrent.FutureTask
, Body: java.util.concurrent.FutureTask@27a9fba8
, Out: null:
]
The next route is "fuzzy" matched via chooseBestPossibleMethodInfo, because
we lost the bean invocation (which was exact). During the fuzzy match, I
get the following exception because somehow camel finds two functions which
are the SAME to qualify:
org.apache.camel.component.bean.AmbiguousMethodCallException: Ambiguous
method invocations possible: [public final
com.mediaplatform.cdc.event.EventData
com.sun.proxy.$Proxy93.syncHandle(com.mediaplatform.cdc.event.EventData)
throws
com.mediaplatform.cdc.consumer.process.handler.exception.HandlerException,
public final com.mediaplatform.cdc.event.EventData
com.sun.proxy.$Proxy93.syncHandle(com.mediaplatform.cdc.event.EventData)
throws
com.mediaplatform.cdc.consumer.process.handler.exception.HandlerException].
Exchange[Message: EventDataImpl{id='null', partitionKey='constant',
vd=VariableDataImpl{} {T=qos, ts=2015-04-29T15:56:07.463Z,
plid=3730a0cd-3a19-41b0-be4a-dd5463e11254,
eid=262f74f5-1ccc-4de6-96dc-0ed5c3191500, TT=timeupdate}}]
at
org.apache.camel.component.bean.BeanInfo.chooseBestPossibleMethodInfo(BeanInfo.java:779)
~[camel-core-2.15.1.jar:2.15.1]
Both methods are EXACTLY the same:
public final com.mediaplatform.cdc.event.EventData
com.sun.proxy.$Proxy93.syncHandle(com.mediaplatform.cdc.event.EventData)
throws
com.mediaplatform.cdc.consumer.process.handler.exception.HandlerException
public final com.mediaplatform.cdc.event.EventData
com.sun.proxy.$Proxy93.syncHandle(com.mediaplatform.cdc.event.EventData)
throws
com.mediaplatform.cdc.consumer.process.handler.exception.HandlerException
So, I am not sure where to go from here. Again, this works perfectly fine
when syncHandle is executed, but breaks with this exception when asyncHandle
is executed.
Thanks.
-AP_
--
View this message in context: http://camel.465427.n5.nabble.com/AmbiguousMethodCallException-but-both-methods-are-the-same-tp5766545.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: AmbiguousMethodCallException but both methods are the same!
Posted by apara <ap...@standardset.com>.
So, I think I figured out what happens. Only the initial invocation on the
proxy is a Method Invocation. So, that un-ambiguously up-calls the
implemented method. However, after the initial invocation, the result is
put into the Exchange, and the exchange continues to carry NOT the
MethodInvocation, but just the result of previous invocation.
>From here on, method matching starts to see who can handle the result.
Since, there are two functions syncHandle and asyncHandle they both can
handle the conversion from a Future<T>, to a T, which I assume is handled by
invoking future.get().
The error message contains exactly the SAME method twice. However, it
should have contained different matching signatures. That would have helped
much in troubleshooting this issue.
I helped Camel up-call the proper function by implementing a:
Future<EventData> asyncHandle(Future<EventData> data) throws
HandlerException;
Where I simply turn around and execute:
@Override
public Future<EventData> asyncHandle(final Future<EventData> data)
throws HandlerException {
return
asyncHandle(
get(
data
)
);
}
So, now, one of the method "exactly" matches the content of the Exchange's
body and invocation occurs without an error.
Just takes a good night of sleep.
-AP_
--
View this message in context: http://camel.465427.n5.nabble.com/AmbiguousMethodCallException-but-both-methods-are-the-same-tp5766545p5766552.html
Sent from the Camel - Users mailing list archive at Nabble.com.