[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Eclipselink, cache coordination
|
To use a SessionCustomizer you need to set it in your persistence.xml,
i.e.
"eclipselink.session.customizer"="org.acme.MySessionCustomizer"
It will be called with the EclipseLink Session before login.
chb75 wrote:
>
> Hi,
>
> sorry for my short post, i was a little frustrated after two days of
> search. Main problem was the JNDI setup.
> I have read a lot and things are getting a little clearer.
>
> I had a whole list of issues:
> - getting openmq to work (easy/out of the box)
> - why do i need a jndi lookup (kind of works with RefFSContextFactory,
> but still don't know why that's necessary) - i thought that telling
> eclipselink where to find the jms-broker should be enough - maybe someone
> can comment on this?
> - setting up jpa (... took a while)
>
> Most of it is taken from
> http://www.nabble.com/Experiments-with-Glassfish-and-coordinated-caching-tt16356582.html
>
>
> protected EntityManagerFactory emf;
> protected String resourceName;
>
> // ...
> public EntityManagerFactory getEMF (){
>
> if (emf == null){
> emf = Persistence.createEntityManagerFactory(resourceName);
> Server session = JpaHelper.getServerSession(emf);
>
> RemoteCommandManager rcm = new
> RemoteCommandManager((CommandProcessor) session);
>
> Hashtable properties = new Hashtable(2);
> properties.put(Context.PROVIDER_URL,"file:///tmp/jndi");
>
> properties.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
>
> JMSTopicTransportManager tm = new
> JMSTopicTransportManager(rcm);
> tm.setTopicHostUrl("tcp://localhost:7676");
> tm.setLocalContextProperties(properties);
> tm.setRemoteContextProperties(properties);
> tm.setTopicName("HelloTopic");
> tm.setTopicConnectionFactoryName("HelloConnectionFactory");
> tm.setUserName("guest");
> tm.setPassword("guest");
>
> rcm.setTransportManager(tm);
>
> ((DatabaseSession)session).setCommandManager(rcm);
>
> session.setShouldPropagateChanges(true);
>
> rcm.initialize();
> }
> return emf;
> }
>
> Annotation seem to work:
> @Cache(coordinationType=CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS)
> public class ...
>
> Oh yes, i threw the settings.xml out of the window.
>
> So comments on why jndi (is there a way without?) would be nice.
>
> I did read about the SessionCustomizer, only I don't know how to use it. I
> can see how I would write one, but how would EclipseLink know about this?
>
> Lot's of thanks
>
> Christoph
>
>
>
> James Sutherland wrote:
>>
>> How are you configuring cache coordination currently? What issue are you
>> currently having?
>>
>> You best option with JPA is to configure cache coordination using a
>> SessionCustomizer. In your customizer you will need to set the
>> RemoteCommandManager for the session. Here is an example for RMI, you
>> will need to change the transport manager to use JMS.
>>
>> RemoteCommandManager cm = new RemoteCommandManager(session);
>>
>> cm.getTransportManager().setNamingServiceType(TransportManager.REGISTRY_NAMING_SERVICE);
>> // set full rmi URL of local host
>> cm.setUrl("rmi://localhost:41099");
>> // turn on cache sync with RCM
>> session.setShouldPropagateChanges(true);
>>
>>
>> chb75 wrote:
>>>
>>> Hello,
>>>
>>> I'm trying to set up a system with hopefully few writes and lots of
>>> reads. I need to be able to scale, so cache coordination seems to be
>>> just the thing. Problem is, I cannot get it started.
>>>
>>> I'm not using the workbench (started with toplink-essentials, jpa).
>>>
>>> I'm using a tomcat together with
>>> OpenMQ
>>>
>>> Trying to configure everything through the settings.xml
>>>
>>> Log messages suggest that the file is read. Looks ok to me.
>>>
>>>
>>> Can someone spot something fundamentelly wrong with this or point me to
>>> some relevant information because although reading the wiki and
>>> searching the net has helped I can't get it off the ground.
>>>
>>
>>
>
>
-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/Eclipselink%2C-cache-coordination-tp20343453p20420723.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.