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: How to impl bean-side of proxy w/Future return?
Date Fri, 15 Jul 2011 05:51:19 GMT
On Wed, Jul 13, 2011 at 7:45 PM, Jason Dillon <jason@planet57.com> wrote:
>> I think support for Future was added in Camel 2.8.
>> http://camel.apache.org/camel-280-release.html
>>
>> Which is also documented here with example
>> http://camel.apache.org/using-camelproxy.html
>
> Yes I've seen+read all of this documentation.
>>
>>> When using proxies and beans to hide all Camel details from the application-layer,
how does one implement the bean-side of the Future returning request?
>>>
>>> public interface SimpleService
>>> {
>>>    Future<String> test();
>>> }
>
>
> My question/point is that you can't really implement this SimpleService interface on
the server-side using Camel bean components:
>
>>> public class SimpleServiceImpl
>>>    implements SimpleService
>>> {
>>>    public Future<String> test() {
>>>        return ???
>>>    }
>>> }
>
> You would have to have:
>
> public interface SimpleServiceServer
> {
>    String test();
> }
>
> and:
>
> public class SimpleServiceServerImpl
>    implements SimpleServiceServer
> {
>    public String test() {
>        return "test";
>    }
> }
>

See this unit test, where you dont have to implement any interface at all
http://svn.apache.org/viewvc?rev=1146964&view=rev


> But when you try then to use a camel-proxy for SimpleService w/ Future<String>
test() the invocation fails, unable to find the correct method:
>
> <snip>
> java.util.concurrent.ExecutionException: java.lang.IllegalAccessException: Class org.apache.camel.component.bean.MethodInfo
can not access a member of class com.sonatype.overlord.xpi.AsyncProxyBeanCamelTest$1 with
modifiers "public"
>        at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
>        at java.util.concurrent.FutureTask.get(FutureTask.java:83)
>        at com.sonatype.overlord.xpi.AsyncProxyBeanCamelTest.simpleService(AsyncProxyBeanCamelTest.java:94)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       ....
> Caused by: java.lang.IllegalAccessException: Class org.apache.camel.component.bean.MethodInfo
can not access a member of class com.sonatype.overlord.xpi.AsyncProxyBeanCamelTest$1 with
modifiers "public"
>        at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
>        at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:329)
>        at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:231)
>        at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:169)
> </snip>
>
> Not a super helpful exception either.
>
>  * * *

I have been trying to reproduce this exception. Can you help me a bit
with showing some of your code that cased this exception?

>
> So it appears that the Future-based async support that has just been added can only be
used on the client-side of a proxy-bean usecase in Camel.
>
> I was hoping to be able to use Camel's proxy + bean features as a replacement for Lingo-style
(http://lingo.codehaus.org/) usecases.  But looks like this isn't easily possible to use
with async implemented asis.  Granted the future-based async is richer than Lingo's oneway
bits, though ATM that is all I'm looking for for async, fire and forget events.
>
> I think there is enough plumbing in Camel to make it work, its just that the current
proxy + bean impls wouldn't be usable.  Or am I wrong in my analysis?
>
> --jason
>
>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message