-
1. Re: PojoCache 2.0 (replicate method execution)
mleur Oct 24, 2006 8:08 AM (in response to mleur)The code in pojocache-aop.xml is :
<prepare expr="execution(public void com.gltrade.manager.sessionmanager.TimerSessionValidity->pingSession() )" /> <introduction class="com.gltrade.manager.sessionmanager.TimerSessionValidity"> <mixin> <interfaces>org.jboss.cache.pojo.observable.Subject</interfaces> <class>org.jboss.cache.pojo.observable.SubjectImpl</class> <construction>new org.jboss.cache.pojo.observable.SubjectImpl(this)</construction> </mixin> </introduction>
-
2. Re: PojoCache 2.0 (replicate method execution)
ben.wang Oct 24, 2006 9:20 PM (in response to mleur)What you need is a remote method call instead of simple replication. And this feature is not directly related to PojoCache if I am reading your post correctly. Instead, to do RPC, you can do like:
CacheSPI s = (CacheSPI)pojoCache.getCache(); RPCManager m = s.getRPCManager(); m.callRemoteMethods(...);
to see how exactly to invoke the callRemoteMethods, you can look into TreeCache implementation. -
3. Re: PojoCache 2.0 (replicate method execution)
mleur Oct 30, 2006 3:51 AM (in response to mleur)Hi,
Thanks for your reply...
But I didn't succeed to do RPC. I execute the code abovePojoCache cache = PojoCacheFactory.createInstance("cache-config.xml"); CacheSPI cacheSPI = (CacheSPI)cache.getCache(); RPCManager rpcManager = cacheSPI.getRPCManager(); TimerSessionValidity timer = new TimerSessionValidity("maxime","id"); Method method = timer.getClass().getMethod("pingSession2",new Class[]{String.class}); cache.attach("timer", timer); timer = (TimerSessionValidity)cache.find("timer"); MethodCall methodCall = MethodCallFactory.create(method,"maxime"); System.out.println("callRemoteMethods "+methodCall.getMethodId()); rpcManager.callRemoteMethods(cacheSPI.getMembers(), methodCall,1,false,(long) 1000);
And I get an Exception :
java.lang.RuntimeException: failure to marshal argument(s)
at org.jgroups.blocks.RpcDispatcher.callRemoteMethods(RpcDispatcher.java:174)
I look at the pojocache & treecache code, and I see that MethodCallFactory call a class named MethodDeclarations which contains all methods names.
How Can I put my method name in this classes ??
Or I am not on the good way.. and can you help me please..
Maxime -
4. Re: PojoCache 2.0 (replicate method execution)
ben.wang Nov 2, 2006 12:50 AM (in response to mleur)Oops! Sorry, RPCManager doesn't do what you need to do. As a matter of fact, with JGroups 2.3 multiplexer, you could have created a multiplexer stack and create your own RPCManager and then have both RPCManager and Cache to share the same channel. However, this process is not straightforward for standalone. I will raise an issue to discuss.
Meanwhile, if don't mind to use separate channel, you can look into org.jboss.cache.rpc.RPCTreeCache. Basically, you can create a separate RPCTreeCache instance (a la TreeCache 1.4 style) and execute your RPC calls there.
Keep in mind the class is deprecated though. -
5. Re: PojoCache 2.0 (replicate method execution)
mleur Nov 3, 2006 9:09 AM (in response to mleur)Hi,
Thanks for your response, I tries to create a new RpcTreeCache and call my method... but it doesn't work again with the same exception.XmlConfigurationParser parser = new XmlConfigurationParser(); Configuration conf = parser.parseFile( "cache-config.xml" ); TimerSessionValidity timer = new TimerSessionValidity("maxime","id"); RpcTreeCache rpcCache = new RpcTreeCache(); rpcCache.setConfiguration(conf); rpcCache.start(); Method method = timer.getClass().getMethod("pingSession2",new Class[]{String.class}); rpcCache.registerRPCHandler("timer", timer); rpcCache.callRemoteMethods("timer",rpcCache.getMembers(), method,new Object[]{ "maxime"}, false, false, (long) 1000);
Could you give a simple code example of RPC calls ???
Because I am lost.
Many Thanks -
6. Re: PojoCache 2.0 (replicate method execution)
ben.wang Nov 7, 2006 3:06 AM (in response to mleur)Looks like there is no easy way of doing RPC on top of JBC since 1.4. This is the relevant discussion thread there:
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3983347#3983347