You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Tobias Schoessler <to...@gmail.com> on 2009/07/29 18:46:22 UTC

sync cayenne cache in two web apps

Hi,

is it possible to sync the cayenne cache of two web applications running in
the same tomcat?

I observe one web app showing outdated data when the other is committing
updates. Both apps are using the same mapping configuration.

Do I need to use remote notification for this?

thanks

Tobias

Re: sync cayenne cache in two web apps

Posted by Mike Kienenberger <mk...@gmail.com>.
Yes, the problem with trying to use a shared variable (DataContext or
cache) is that a typical web app really isn't designed for that
methodology to be practical.   Normally your  DataContext or cache
would be per request or per session.

I could be wrong, but I don't think there's all that much overhead.
Guesswork based on past experiencies, but the messages are probably
sent asynchronously, so the sending app's performance only
deteriorates by the time it takes to send that information in a
separate thread -- might be almost zero for a multiprocessor system.

The reading system has the overhead of reading a socket, then
processing the messages.   Again, that should be negligible since the
socket reader will only wake up if there's a message to read, and the
synchronization part of the code would have to execute no matter what
you did.

On Thu, Jul 30, 2009 at 5:23 PM, Tobias
Schoessler<to...@gmail.com> wrote:
> So thank you for all the suggestions. The solution we finally ended up with
> was the one Mike actually suggested intitially. We got our multicast ip,
> dropped the latest Jgroups.jar into both webapps lib directories, selected
> Jgroups as the Syncronisation mechanism in the cayenne modeller, used the
> default jgroups udp.xml config file patched with our multicast ip address
> and 'snapp' the contexts were synchronized. Very satisfying - Cayenne
> rocks.! :)
>
> Before this I went down the route of trying to make cayenne use the global
> JVM scope to store the shared cache. I moved the cayenne.jar up on the
> tomcat shared lib directory, out of the two web app lib folders. This did
> not work out well, I got stuck at the point where one web app worked fine
> the other one threw class cast exception on the mapping objects saying it
> cannot cast the types on itself. I assume this is due to the fact that both
> webapps had their own copies of the mapping classes. I tried moving them up
> into the shared tomcat lib aswell, but  then they could not see the web app
> specific classes anymore. So anyway I am happy with our Jgroups solution
> now.
>
> The documentation reads lthis setup has some overhead. Does anybody have
> experience/numbers how much performance you loose when using jgroups
> syncronised caches compared to local cache?
>
> thanks again everyone.
>
> On Thu, Jul 30, 2009 at 10:47 AM, Tobias Schoessler <
> tobias.schoessler@gmail.com> wrote:
>
>> Thanks everyone for the posts.
>>
>> @Mike, I am still not convinced that using the Remote Notification Feature
>> is really nessecary here. After all, there seems to be a JVM shared between
>> webapps in Tomcat and the article posted seems to proof that there is a
>> possiblity to share information between the webapps on a JVM level. So I
>> think that using Remote Notification, which I understand to be designed for
>> Cross JVM notification creates too much overhead.
>>
>> You mentioned the possibility of sharing the DataContext between the
>> webapps. I think I have to explore this possibility first, as this would
>> have less overhead compared to the notification based solution.
>> Currently I am using the
>> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(request.getSession())
>> to obtain my DataContexts per request.
>> If I could change the scope the DataContexts are stored to cross web app
>> scope instead of session scope I could share the DataContexts between the
>> two web apps. Assuming that I can setup the two webapps to share the same
>> session Ids as described in the article.
>>
>> This might be a no go for me as the two contexts use different
>> authentication realms - I have to check this. But even then wouldn't it be
>> possbile to configure the cayenne shared cache to use this cross web context
>> scope for its shared cache. Then I could use
>> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(session) in the
>> two web apps transparently and cayenne would refresh the DataContext from
>> this shared cache in the background. Could somebody point me to where this
>> shared cayenne cache is configured to have its scope? I assume it uses JVM
>> static scope?
>>
>> @Malcolm, thanks for suggesting this alternative. If I understand you
>> correctly you suggest to switch off the cayenne cache alltogether and use
>> the jsptag based caching of the OScache project? The problem with this is
>> that not all my responses are generated from jsptags. I have many ajax
>> requests generating json responses without bothering the jsp container.
>>
>> Tobias
>>
>>
>> On Thu, Jul 30, 2009 at 3:00 AM, Malcolm Edgar <ma...@gmail.com>wrote:
>>
>>> You can also use OSCache with Cayenne and have the cached queries
>>> expire frequently, i.e. after 30 seconds
>>>
>>> regards Malcolm Edgar
>>>
>>> On Thu, Jul 30, 2009 at 6:36 AM, Mike Kienenberger<mk...@gmail.com>
>>> wrote:
>>> > Before you make your own custom solution, you might want to read up on
>>> > Javagroup.  It might not be a problem to use it in your environment.
>>> >
>>> > The main page starts off with this:
>>> >
>>> > http://www.jgroups.org/
>>> > ==================================
>>> > JGroups is a toolkit for reliable multicast communication.
>>> > (Note that this doesn't necessarily mean IP Multicast, JGroups can
>>> > also use transports such as TCP).
>>> >
>>> > [...]
>>> >
>>> > JGroups comes with a number of protocols (but anyone can write their
>>> > own), for example
>>> >    * Transport protocols: UDP (IP Multicast), TCP, JMS
>>> >
>>> > ==================================
>>> >
>>> > So even if the TCP version doesn't do what you need, you might find it
>>> > easier to write your own Jgroup protocol than to write your own
>>> > cayenne event bridge.  It's more likely to be documented and there
>>> > will be more examples/end users to ask questions of.  There might even
>>> > be a tomcat shared session protocol out there somewhere.
>>> >
>>> >
>>> > On Wed, Jul 29, 2009 at 4:16 PM, Tobias
>>> > Schoessler<to...@gmail.com> wrote:
>>> >> well i am reading this from the documentation:
>>> >>
>>> >> "... At the minimum, JMS setup requires a JMS server running, and
>>> subjects
>>> >> for each of the DataDomains to be configured. JavaGroups is
>>> peer-to-peer
>>> >> library that is embedded into applications. Default configuration
>>> provided
>>> >> by CayenneModeler will work out of the box, provided that IP multicast
>>> is
>>> >> enabled on the network."
>>> >>
>>> >> for the JMS solution the JMS server setup is a problem
>>> >> for the JavaGroups setup the "IP multicast is enabled on the network."
>>>  is a
>>> >> problem
>>> >>
>>> >> so  for the custom tranport mechanism that you mentioned I stumbled
>>> upon
>>> >> this here
>>> >>
>>> >>
>>> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>>> >>
>>> >> which seems to describe cross context data sharing on tomcat web
>>> contexts
>>> >>
>>> >> but is there any code to look at to see how a custom transport
>>> mechanism can
>>> >> be setup?
>>> >>
>>> >> Tobias
>>> >>
>>> >>
>>> >> On Wed, Jul 29, 2009 at 8:28 PM, Mike Kienenberger <mkienenb@gmail.com
>>> >wrote:
>>> >>
>>> >>> I've never set it up, but it's easily configurable.
>>> >>>
>>> >>> If you don't like the javagroups or JMS methodologies, you can define
>>> >>> your own -- I don't know what tomcat app-data-sharing ability is
>>> >>> available -- it probably depends on the container, but I don't
>>> >>> remember reading about any in the past.
>>> >>>
>>> >>> However, the docs seem to indicate that using Javagroups is pretty
>>> >>> painless with no external configuration to deal with.
>>> >>>
>>> >>> I have a Cayenne 1.1.x application I wrote that used remote
>>> >>> notification internally to broadcast events between sessions, so I
>>> >>> know it's not difficult to set up and define your own event
>>> >>> broadcaster.  My guess is that doing it for javagroups is pretty easy
>>> >>> since it sounds like a matter of just filling in the forms on the
>>> >>> modeler.
>>> >>>
>>> >>> On Wed, Jul 29, 2009 at 2:15 PM, Tobias
>>> >>> Schoessler<to...@gmail.com> wrote:
>>> >>> > Thanks Mike,
>>> >>> >
>>> >>> > so the answer is yes, this can only be done using remote
>>> notification? is
>>> >>> > this correct?
>>> >>> >
>>> >>> > Isn't there a way to share the cache among two web application
>>> scopes
>>> >>> > without going through the hassle of setting up remote notification?
>>> >>> >
>>> >>> > When the two webapps are running on the same physical machine,
>>> inside the
>>> >>> > same application server this seems overkill.
>>> >>> >
>>> >>> > Tobias
>>> >>> >
>>> >>> > On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <
>>> mkienenb@gmail.com
>>> >>> >wrote:
>>> >>> >
>>> >>> >> Yes,
>>> >>> >>
>>> >>> >> Here's a Cayenne 2.0 document on it:
>>> >>> >>
>>> >>> >> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
>>> >>> >>
>>> >>> >> For 3.0:
>>> >>> >>
>>> >>> >> http://cayenne.apache.org/doc/configuring-caching-behavior.html
>>> >>> >>
>>> >>> >> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
>>> >>> >> Schoessler<to...@gmail.com> wrote:
>>> >>> >> > Hi,
>>> >>> >> >
>>> >>> >> > is it possible to sync the cayenne cache of two web applications
>>> >>> running
>>> >>> >> in
>>> >>> >> > the same tomcat?
>>> >>> >> >
>>> >>> >> > I observe one web app showing outdated data when the other is
>>> >>> committing
>>> >>> >> > updates. Both apps are using the same mapping configuration.
>>> >>> >> >
>>> >>> >> > Do I need to use remote notification for this?
>>> >>> >> >
>>> >>> >> > thanks
>>> >>> >> >
>>> >>> >> > Tobias
>>> >>> >> >
>>> >>> >>
>>> >>> >
>>> >>>
>>> >>
>>> >
>>>
>>
>>
>

Re: sync cayenne cache in two web apps

Posted by Mike Kienenberger <mk...@gmail.com>.
Again, if you're really concerned about performance and impact, my
guess is that it would be trivial to replace the JGroup protocol with
a unix pipe instead of a network socket implementation, if you're on
an OS that supports it.

On Thu, Jul 30, 2009 at 5:43 PM, Mike Kienenberger<mk...@gmail.com> wrote:
> I don't remember the specific implementation, and it might vary for
> JavaGroups over what is used internally.  You really don't need to use
> multicast if you only have two apps.   I'd go with the TCP setup, both
> for reliability and to limit the impact on the rest of the network.
> The same traffic probably goes over the wire, but the other machines
> won't process those packets.
>
> Your best bet is to look at the EventBridge code and see what kind of
> data it sends out.  It might vary between event types if it doesn't
> simply fault those objects.
>
> On Thu, Jul 30, 2009 at 5:37 PM, Tobias
> Schoessler<to...@gmail.com> wrote:
>> yes that's what I observe too. The messages sent when these updates occure,
>> do they contain the change infromation or only the information which objects
>> to invalidate? I got this asked when I asked for the multicast address, to
>> estiamte traffic for this setup.
>>
>> On Thu, Jul 30, 2009 at 11:33 PM, Michael Gentry <mg...@masslight.net>wrote:
>>
>>> Hi Tobias,
>>>
>>> I've not used the cache synchronization before, but I was under the
>>> impression that the main overhead is when inserts/updates/deletes are
>>> done, not when selects are done.  When you do an insert/update/delete,
>>> that information must be broadcast, but selects do not.  I'm sure
>>> someone will correct me if I am wrong on this.  :-)
>>>
>>> mrg
>>>
>>>
>>> On Thu, Jul 30, 2009 at 5:23 PM, Tobias
>>> Schoessler<to...@gmail.com> wrote:
>>> > So thank you for all the suggestions. The solution we finally ended up
>>> with
>>> > was the one Mike actually suggested intitially. We got our multicast ip,
>>> > dropped the latest Jgroups.jar into both webapps lib directories,
>>> selected
>>> > Jgroups as the Syncronisation mechanism in the cayenne modeller, used the
>>> > default jgroups udp.xml config file patched with our multicast ip address
>>> > and 'snapp' the contexts were synchronized. Very satisfying - Cayenne
>>> > rocks.! :)
>>> >
>>> > Before this I went down the route of trying to make cayenne use the
>>> global
>>> > JVM scope to store the shared cache. I moved the cayenne.jar up on the
>>> > tomcat shared lib directory, out of the two web app lib folders. This did
>>> > not work out well, I got stuck at the point where one web app worked fine
>>> > the other one threw class cast exception on the mapping objects saying it
>>> > cannot cast the types on itself. I assume this is due to the fact that
>>> both
>>> > webapps had their own copies of the mapping classes. I tried moving them
>>> up
>>> > into the shared tomcat lib aswell, but  then they could not see the web
>>> app
>>> > specific classes anymore. So anyway I am happy with our Jgroups solution
>>> > now.
>>> >
>>> > The documentation reads lthis setup has some overhead. Does anybody have
>>> > experience/numbers how much performance you loose when using jgroups
>>> > syncronised caches compared to local cache?
>>> >
>>> > thanks again everyone.
>>> >
>>> > On Thu, Jul 30, 2009 at 10:47 AM, Tobias Schoessler <
>>> > tobias.schoessler@gmail.com> wrote:
>>> >
>>> >> Thanks everyone for the posts.
>>> >>
>>> >> @Mike, I am still not convinced that using the Remote Notification
>>> Feature
>>> >> is really nessecary here. After all, there seems to be a JVM shared
>>> between
>>> >> webapps in Tomcat and the article posted seems to proof that there is a
>>> >> possiblity to share information between the webapps on a JVM level. So I
>>> >> think that using Remote Notification, which I understand to be designed
>>> for
>>> >> Cross JVM notification creates too much overhead.
>>> >>
>>> >> You mentioned the possibility of sharing the DataContext between the
>>> >> webapps. I think I have to explore this possibility first, as this would
>>> >> have less overhead compared to the notification based solution.
>>> >> Currently I am using the
>>> >>
>>> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(request.getSession())
>>> >> to obtain my DataContexts per request.
>>> >> If I could change the scope the DataContexts are stored to cross web app
>>> >> scope instead of session scope I could share the DataContexts between
>>> the
>>> >> two web apps. Assuming that I can setup the two webapps to share the
>>> same
>>> >> session Ids as described in the article.
>>> >>
>>> >> This might be a no go for me as the two contexts use different
>>> >> authentication realms - I have to check this. But even then wouldn't it
>>> be
>>> >> possbile to configure the cayenne shared cache to use this cross web
>>> context
>>> >> scope for its shared cache. Then I could use
>>> >> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(session) in
>>> the
>>> >> two web apps transparently and cayenne would refresh the DataContext
>>> from
>>> >> this shared cache in the background. Could somebody point me to where
>>> this
>>> >> shared cayenne cache is configured to have its scope? I assume it uses
>>> JVM
>>> >> static scope?
>>> >>
>>> >> @Malcolm, thanks for suggesting this alternative. If I understand you
>>> >> correctly you suggest to switch off the cayenne cache alltogether and
>>> use
>>> >> the jsptag based caching of the OScache project? The problem with this
>>> is
>>> >> that not all my responses are generated from jsptags. I have many ajax
>>> >> requests generating json responses without bothering the jsp container.
>>> >>
>>> >> Tobias
>>> >>
>>> >>
>>> >> On Thu, Jul 30, 2009 at 3:00 AM, Malcolm Edgar <malcolm.edgar@gmail.com
>>> >wrote:
>>> >>
>>> >>> You can also use OSCache with Cayenne and have the cached queries
>>> >>> expire frequently, i.e. after 30 seconds
>>> >>>
>>> >>> regards Malcolm Edgar
>>> >>>
>>> >>> On Thu, Jul 30, 2009 at 6:36 AM, Mike Kienenberger<mk...@gmail.com>
>>> >>> wrote:
>>> >>> > Before you make your own custom solution, you might want to read up
>>> on
>>> >>> > Javagroup.  It might not be a problem to use it in your environment.
>>> >>> >
>>> >>> > The main page starts off with this:
>>> >>> >
>>> >>> > http://www.jgroups.org/
>>> >>> > ==================================
>>> >>> > JGroups is a toolkit for reliable multicast communication.
>>> >>> > (Note that this doesn't necessarily mean IP Multicast, JGroups can
>>> >>> > also use transports such as TCP).
>>> >>> >
>>> >>> > [...]
>>> >>> >
>>> >>> > JGroups comes with a number of protocols (but anyone can write their
>>> >>> > own), for example
>>> >>> >    * Transport protocols: UDP (IP Multicast), TCP, JMS
>>> >>> >
>>> >>> > ==================================
>>> >>> >
>>> >>> > So even if the TCP version doesn't do what you need, you might find
>>> it
>>> >>> > easier to write your own Jgroup protocol than to write your own
>>> >>> > cayenne event bridge.  It's more likely to be documented and there
>>> >>> > will be more examples/end users to ask questions of.  There might
>>> even
>>> >>> > be a tomcat shared session protocol out there somewhere.
>>> >>> >
>>> >>> >
>>> >>> > On Wed, Jul 29, 2009 at 4:16 PM, Tobias
>>> >>> > Schoessler<to...@gmail.com> wrote:
>>> >>> >> well i am reading this from the documentation:
>>> >>> >>
>>> >>> >> "... At the minimum, JMS setup requires a JMS server running, and
>>> >>> subjects
>>> >>> >> for each of the DataDomains to be configured. JavaGroups is
>>> >>> peer-to-peer
>>> >>> >> library that is embedded into applications. Default configuration
>>> >>> provided
>>> >>> >> by CayenneModeler will work out of the box, provided that IP
>>> multicast
>>> >>> is
>>> >>> >> enabled on the network."
>>> >>> >>
>>> >>> >> for the JMS solution the JMS server setup is a problem
>>> >>> >> for the JavaGroups setup the "IP multicast is enabled on the
>>> network."
>>> >>>  is a
>>> >>> >> problem
>>> >>> >>
>>> >>> >> so  for the custom tranport mechanism that you mentioned I stumbled
>>> >>> upon
>>> >>> >> this here
>>> >>> >>
>>> >>> >>
>>> >>>
>>> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>>> >>> >>
>>> >>> >> which seems to describe cross context data sharing on tomcat web
>>> >>> contexts
>>> >>> >>
>>> >>> >> but is there any code to look at to see how a custom transport
>>> >>> mechanism can
>>> >>> >> be setup?
>>> >>> >>
>>> >>> >> Tobias
>>> >>> >>
>>> >>> >>
>>> >>> >> On Wed, Jul 29, 2009 at 8:28 PM, Mike Kienenberger <
>>> mkienenb@gmail.com
>>> >>> >wrote:
>>> >>> >>
>>> >>> >>> I've never set it up, but it's easily configurable.
>>> >>> >>>
>>> >>> >>> If you don't like the javagroups or JMS methodologies, you can
>>> define
>>> >>> >>> your own -- I don't know what tomcat app-data-sharing ability is
>>> >>> >>> available -- it probably depends on the container, but I don't
>>> >>> >>> remember reading about any in the past.
>>> >>> >>>
>>> >>> >>> However, the docs seem to indicate that using Javagroups is pretty
>>> >>> >>> painless with no external configuration to deal with.
>>> >>> >>>
>>> >>> >>> I have a Cayenne 1.1.x application I wrote that used remote
>>> >>> >>> notification internally to broadcast events between sessions, so I
>>> >>> >>> know it's not difficult to set up and define your own event
>>> >>> >>> broadcaster.  My guess is that doing it for javagroups is pretty
>>> easy
>>> >>> >>> since it sounds like a matter of just filling in the forms on the
>>> >>> >>> modeler.
>>> >>> >>>
>>> >>> >>> On Wed, Jul 29, 2009 at 2:15 PM, Tobias
>>> >>> >>> Schoessler<to...@gmail.com> wrote:
>>> >>> >>> > Thanks Mike,
>>> >>> >>> >
>>> >>> >>> > so the answer is yes, this can only be done using remote
>>> >>> notification? is
>>> >>> >>> > this correct?
>>> >>> >>> >
>>> >>> >>> > Isn't there a way to share the cache among two web application
>>> >>> scopes
>>> >>> >>> > without going through the hassle of setting up remote
>>> notification?
>>> >>> >>> >
>>> >>> >>> > When the two webapps are running on the same physical machine,
>>> >>> inside the
>>> >>> >>> > same application server this seems overkill.
>>> >>> >>> >
>>> >>> >>> > Tobias
>>> >>> >>> >
>>> >>> >>> > On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <
>>> >>> mkienenb@gmail.com
>>> >>> >>> >wrote:
>>> >>> >>> >
>>> >>> >>> >> Yes,
>>> >>> >>> >>
>>> >>> >>> >> Here's a Cayenne 2.0 document on it:
>>> >>> >>> >>
>>> >>> >>> >>
>>> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
>>> >>> >>> >>
>>> >>> >>> >> For 3.0:
>>> >>> >>> >>
>>> >>> >>> >> http://cayenne.apache.org/doc/configuring-caching-behavior.html
>>> >>> >>> >>
>>> >>> >>> >> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
>>> >>> >>> >> Schoessler<to...@gmail.com> wrote:
>>> >>> >>> >> > Hi,
>>> >>> >>> >> >
>>> >>> >>> >> > is it possible to sync the cayenne cache of two web
>>> applications
>>> >>> >>> running
>>> >>> >>> >> in
>>> >>> >>> >> > the same tomcat?
>>> >>> >>> >> >
>>> >>> >>> >> > I observe one web app showing outdated data when the other is
>>> >>> >>> committing
>>> >>> >>> >> > updates. Both apps are using the same mapping configuration.
>>> >>> >>> >> >
>>> >>> >>> >> > Do I need to use remote notification for this?
>>> >>> >>> >> >
>>> >>> >>> >> > thanks
>>> >>> >>> >> >
>>> >>> >>> >> > Tobias
>>> >>> >>> >> >
>>> >>> >>> >>
>>> >>> >>> >
>>> >>> >>>
>>> >>> >>
>>> >>> >
>>> >>>
>>> >>
>>> >>
>>> >
>>>
>>
>

Re: sync cayenne cache in two web apps

Posted by Mike Kienenberger <mk...@gmail.com>.
I don't remember the specific implementation, and it might vary for
JavaGroups over what is used internally.  You really don't need to use
multicast if you only have two apps.   I'd go with the TCP setup, both
for reliability and to limit the impact on the rest of the network.
The same traffic probably goes over the wire, but the other machines
won't process those packets.

Your best bet is to look at the EventBridge code and see what kind of
data it sends out.  It might vary between event types if it doesn't
simply fault those objects.

On Thu, Jul 30, 2009 at 5:37 PM, Tobias
Schoessler<to...@gmail.com> wrote:
> yes that's what I observe too. The messages sent when these updates occure,
> do they contain the change infromation or only the information which objects
> to invalidate? I got this asked when I asked for the multicast address, to
> estiamte traffic for this setup.
>
> On Thu, Jul 30, 2009 at 11:33 PM, Michael Gentry <mg...@masslight.net>wrote:
>
>> Hi Tobias,
>>
>> I've not used the cache synchronization before, but I was under the
>> impression that the main overhead is when inserts/updates/deletes are
>> done, not when selects are done.  When you do an insert/update/delete,
>> that information must be broadcast, but selects do not.  I'm sure
>> someone will correct me if I am wrong on this.  :-)
>>
>> mrg
>>
>>
>> On Thu, Jul 30, 2009 at 5:23 PM, Tobias
>> Schoessler<to...@gmail.com> wrote:
>> > So thank you for all the suggestions. The solution we finally ended up
>> with
>> > was the one Mike actually suggested intitially. We got our multicast ip,
>> > dropped the latest Jgroups.jar into both webapps lib directories,
>> selected
>> > Jgroups as the Syncronisation mechanism in the cayenne modeller, used the
>> > default jgroups udp.xml config file patched with our multicast ip address
>> > and 'snapp' the contexts were synchronized. Very satisfying - Cayenne
>> > rocks.! :)
>> >
>> > Before this I went down the route of trying to make cayenne use the
>> global
>> > JVM scope to store the shared cache. I moved the cayenne.jar up on the
>> > tomcat shared lib directory, out of the two web app lib folders. This did
>> > not work out well, I got stuck at the point where one web app worked fine
>> > the other one threw class cast exception on the mapping objects saying it
>> > cannot cast the types on itself. I assume this is due to the fact that
>> both
>> > webapps had their own copies of the mapping classes. I tried moving them
>> up
>> > into the shared tomcat lib aswell, but  then they could not see the web
>> app
>> > specific classes anymore. So anyway I am happy with our Jgroups solution
>> > now.
>> >
>> > The documentation reads lthis setup has some overhead. Does anybody have
>> > experience/numbers how much performance you loose when using jgroups
>> > syncronised caches compared to local cache?
>> >
>> > thanks again everyone.
>> >
>> > On Thu, Jul 30, 2009 at 10:47 AM, Tobias Schoessler <
>> > tobias.schoessler@gmail.com> wrote:
>> >
>> >> Thanks everyone for the posts.
>> >>
>> >> @Mike, I am still not convinced that using the Remote Notification
>> Feature
>> >> is really nessecary here. After all, there seems to be a JVM shared
>> between
>> >> webapps in Tomcat and the article posted seems to proof that there is a
>> >> possiblity to share information between the webapps on a JVM level. So I
>> >> think that using Remote Notification, which I understand to be designed
>> for
>> >> Cross JVM notification creates too much overhead.
>> >>
>> >> You mentioned the possibility of sharing the DataContext between the
>> >> webapps. I think I have to explore this possibility first, as this would
>> >> have less overhead compared to the notification based solution.
>> >> Currently I am using the
>> >>
>> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(request.getSession())
>> >> to obtain my DataContexts per request.
>> >> If I could change the scope the DataContexts are stored to cross web app
>> >> scope instead of session scope I could share the DataContexts between
>> the
>> >> two web apps. Assuming that I can setup the two webapps to share the
>> same
>> >> session Ids as described in the article.
>> >>
>> >> This might be a no go for me as the two contexts use different
>> >> authentication realms - I have to check this. But even then wouldn't it
>> be
>> >> possbile to configure the cayenne shared cache to use this cross web
>> context
>> >> scope for its shared cache. Then I could use
>> >> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(session) in
>> the
>> >> two web apps transparently and cayenne would refresh the DataContext
>> from
>> >> this shared cache in the background. Could somebody point me to where
>> this
>> >> shared cayenne cache is configured to have its scope? I assume it uses
>> JVM
>> >> static scope?
>> >>
>> >> @Malcolm, thanks for suggesting this alternative. If I understand you
>> >> correctly you suggest to switch off the cayenne cache alltogether and
>> use
>> >> the jsptag based caching of the OScache project? The problem with this
>> is
>> >> that not all my responses are generated from jsptags. I have many ajax
>> >> requests generating json responses without bothering the jsp container.
>> >>
>> >> Tobias
>> >>
>> >>
>> >> On Thu, Jul 30, 2009 at 3:00 AM, Malcolm Edgar <malcolm.edgar@gmail.com
>> >wrote:
>> >>
>> >>> You can also use OSCache with Cayenne and have the cached queries
>> >>> expire frequently, i.e. after 30 seconds
>> >>>
>> >>> regards Malcolm Edgar
>> >>>
>> >>> On Thu, Jul 30, 2009 at 6:36 AM, Mike Kienenberger<mk...@gmail.com>
>> >>> wrote:
>> >>> > Before you make your own custom solution, you might want to read up
>> on
>> >>> > Javagroup.  It might not be a problem to use it in your environment.
>> >>> >
>> >>> > The main page starts off with this:
>> >>> >
>> >>> > http://www.jgroups.org/
>> >>> > ==================================
>> >>> > JGroups is a toolkit for reliable multicast communication.
>> >>> > (Note that this doesn't necessarily mean IP Multicast, JGroups can
>> >>> > also use transports such as TCP).
>> >>> >
>> >>> > [...]
>> >>> >
>> >>> > JGroups comes with a number of protocols (but anyone can write their
>> >>> > own), for example
>> >>> >    * Transport protocols: UDP (IP Multicast), TCP, JMS
>> >>> >
>> >>> > ==================================
>> >>> >
>> >>> > So even if the TCP version doesn't do what you need, you might find
>> it
>> >>> > easier to write your own Jgroup protocol than to write your own
>> >>> > cayenne event bridge.  It's more likely to be documented and there
>> >>> > will be more examples/end users to ask questions of.  There might
>> even
>> >>> > be a tomcat shared session protocol out there somewhere.
>> >>> >
>> >>> >
>> >>> > On Wed, Jul 29, 2009 at 4:16 PM, Tobias
>> >>> > Schoessler<to...@gmail.com> wrote:
>> >>> >> well i am reading this from the documentation:
>> >>> >>
>> >>> >> "... At the minimum, JMS setup requires a JMS server running, and
>> >>> subjects
>> >>> >> for each of the DataDomains to be configured. JavaGroups is
>> >>> peer-to-peer
>> >>> >> library that is embedded into applications. Default configuration
>> >>> provided
>> >>> >> by CayenneModeler will work out of the box, provided that IP
>> multicast
>> >>> is
>> >>> >> enabled on the network."
>> >>> >>
>> >>> >> for the JMS solution the JMS server setup is a problem
>> >>> >> for the JavaGroups setup the "IP multicast is enabled on the
>> network."
>> >>>  is a
>> >>> >> problem
>> >>> >>
>> >>> >> so  for the custom tranport mechanism that you mentioned I stumbled
>> >>> upon
>> >>> >> this here
>> >>> >>
>> >>> >>
>> >>>
>> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>> >>> >>
>> >>> >> which seems to describe cross context data sharing on tomcat web
>> >>> contexts
>> >>> >>
>> >>> >> but is there any code to look at to see how a custom transport
>> >>> mechanism can
>> >>> >> be setup?
>> >>> >>
>> >>> >> Tobias
>> >>> >>
>> >>> >>
>> >>> >> On Wed, Jul 29, 2009 at 8:28 PM, Mike Kienenberger <
>> mkienenb@gmail.com
>> >>> >wrote:
>> >>> >>
>> >>> >>> I've never set it up, but it's easily configurable.
>> >>> >>>
>> >>> >>> If you don't like the javagroups or JMS methodologies, you can
>> define
>> >>> >>> your own -- I don't know what tomcat app-data-sharing ability is
>> >>> >>> available -- it probably depends on the container, but I don't
>> >>> >>> remember reading about any in the past.
>> >>> >>>
>> >>> >>> However, the docs seem to indicate that using Javagroups is pretty
>> >>> >>> painless with no external configuration to deal with.
>> >>> >>>
>> >>> >>> I have a Cayenne 1.1.x application I wrote that used remote
>> >>> >>> notification internally to broadcast events between sessions, so I
>> >>> >>> know it's not difficult to set up and define your own event
>> >>> >>> broadcaster.  My guess is that doing it for javagroups is pretty
>> easy
>> >>> >>> since it sounds like a matter of just filling in the forms on the
>> >>> >>> modeler.
>> >>> >>>
>> >>> >>> On Wed, Jul 29, 2009 at 2:15 PM, Tobias
>> >>> >>> Schoessler<to...@gmail.com> wrote:
>> >>> >>> > Thanks Mike,
>> >>> >>> >
>> >>> >>> > so the answer is yes, this can only be done using remote
>> >>> notification? is
>> >>> >>> > this correct?
>> >>> >>> >
>> >>> >>> > Isn't there a way to share the cache among two web application
>> >>> scopes
>> >>> >>> > without going through the hassle of setting up remote
>> notification?
>> >>> >>> >
>> >>> >>> > When the two webapps are running on the same physical machine,
>> >>> inside the
>> >>> >>> > same application server this seems overkill.
>> >>> >>> >
>> >>> >>> > Tobias
>> >>> >>> >
>> >>> >>> > On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <
>> >>> mkienenb@gmail.com
>> >>> >>> >wrote:
>> >>> >>> >
>> >>> >>> >> Yes,
>> >>> >>> >>
>> >>> >>> >> Here's a Cayenne 2.0 document on it:
>> >>> >>> >>
>> >>> >>> >>
>> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
>> >>> >>> >>
>> >>> >>> >> For 3.0:
>> >>> >>> >>
>> >>> >>> >> http://cayenne.apache.org/doc/configuring-caching-behavior.html
>> >>> >>> >>
>> >>> >>> >> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
>> >>> >>> >> Schoessler<to...@gmail.com> wrote:
>> >>> >>> >> > Hi,
>> >>> >>> >> >
>> >>> >>> >> > is it possible to sync the cayenne cache of two web
>> applications
>> >>> >>> running
>> >>> >>> >> in
>> >>> >>> >> > the same tomcat?
>> >>> >>> >> >
>> >>> >>> >> > I observe one web app showing outdated data when the other is
>> >>> >>> committing
>> >>> >>> >> > updates. Both apps are using the same mapping configuration.
>> >>> >>> >> >
>> >>> >>> >> > Do I need to use remote notification for this?
>> >>> >>> >> >
>> >>> >>> >> > thanks
>> >>> >>> >> >
>> >>> >>> >> > Tobias
>> >>> >>> >> >
>> >>> >>> >>
>> >>> >>> >
>> >>> >>>
>> >>> >>
>> >>> >
>> >>>
>> >>
>> >>
>> >
>>
>

Re: sync cayenne cache in two web apps

Posted by Tobias Schoessler <to...@gmail.com>.
yes that's what I observe too. The messages sent when these updates occure,
do they contain the change infromation or only the information which objects
to invalidate? I got this asked when I asked for the multicast address, to
estiamte traffic for this setup.

On Thu, Jul 30, 2009 at 11:33 PM, Michael Gentry <mg...@masslight.net>wrote:

> Hi Tobias,
>
> I've not used the cache synchronization before, but I was under the
> impression that the main overhead is when inserts/updates/deletes are
> done, not when selects are done.  When you do an insert/update/delete,
> that information must be broadcast, but selects do not.  I'm sure
> someone will correct me if I am wrong on this.  :-)
>
> mrg
>
>
> On Thu, Jul 30, 2009 at 5:23 PM, Tobias
> Schoessler<to...@gmail.com> wrote:
> > So thank you for all the suggestions. The solution we finally ended up
> with
> > was the one Mike actually suggested intitially. We got our multicast ip,
> > dropped the latest Jgroups.jar into both webapps lib directories,
> selected
> > Jgroups as the Syncronisation mechanism in the cayenne modeller, used the
> > default jgroups udp.xml config file patched with our multicast ip address
> > and 'snapp' the contexts were synchronized. Very satisfying - Cayenne
> > rocks.! :)
> >
> > Before this I went down the route of trying to make cayenne use the
> global
> > JVM scope to store the shared cache. I moved the cayenne.jar up on the
> > tomcat shared lib directory, out of the two web app lib folders. This did
> > not work out well, I got stuck at the point where one web app worked fine
> > the other one threw class cast exception on the mapping objects saying it
> > cannot cast the types on itself. I assume this is due to the fact that
> both
> > webapps had their own copies of the mapping classes. I tried moving them
> up
> > into the shared tomcat lib aswell, but  then they could not see the web
> app
> > specific classes anymore. So anyway I am happy with our Jgroups solution
> > now.
> >
> > The documentation reads lthis setup has some overhead. Does anybody have
> > experience/numbers how much performance you loose when using jgroups
> > syncronised caches compared to local cache?
> >
> > thanks again everyone.
> >
> > On Thu, Jul 30, 2009 at 10:47 AM, Tobias Schoessler <
> > tobias.schoessler@gmail.com> wrote:
> >
> >> Thanks everyone for the posts.
> >>
> >> @Mike, I am still not convinced that using the Remote Notification
> Feature
> >> is really nessecary here. After all, there seems to be a JVM shared
> between
> >> webapps in Tomcat and the article posted seems to proof that there is a
> >> possiblity to share information between the webapps on a JVM level. So I
> >> think that using Remote Notification, which I understand to be designed
> for
> >> Cross JVM notification creates too much overhead.
> >>
> >> You mentioned the possibility of sharing the DataContext between the
> >> webapps. I think I have to explore this possibility first, as this would
> >> have less overhead compared to the notification based solution.
> >> Currently I am using the
> >>
> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(request.getSession())
> >> to obtain my DataContexts per request.
> >> If I could change the scope the DataContexts are stored to cross web app
> >> scope instead of session scope I could share the DataContexts between
> the
> >> two web apps. Assuming that I can setup the two webapps to share the
> same
> >> session Ids as described in the article.
> >>
> >> This might be a no go for me as the two contexts use different
> >> authentication realms - I have to check this. But even then wouldn't it
> be
> >> possbile to configure the cayenne shared cache to use this cross web
> context
> >> scope for its shared cache. Then I could use
> >> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(session) in
> the
> >> two web apps transparently and cayenne would refresh the DataContext
> from
> >> this shared cache in the background. Could somebody point me to where
> this
> >> shared cayenne cache is configured to have its scope? I assume it uses
> JVM
> >> static scope?
> >>
> >> @Malcolm, thanks for suggesting this alternative. If I understand you
> >> correctly you suggest to switch off the cayenne cache alltogether and
> use
> >> the jsptag based caching of the OScache project? The problem with this
> is
> >> that not all my responses are generated from jsptags. I have many ajax
> >> requests generating json responses without bothering the jsp container.
> >>
> >> Tobias
> >>
> >>
> >> On Thu, Jul 30, 2009 at 3:00 AM, Malcolm Edgar <malcolm.edgar@gmail.com
> >wrote:
> >>
> >>> You can also use OSCache with Cayenne and have the cached queries
> >>> expire frequently, i.e. after 30 seconds
> >>>
> >>> regards Malcolm Edgar
> >>>
> >>> On Thu, Jul 30, 2009 at 6:36 AM, Mike Kienenberger<mk...@gmail.com>
> >>> wrote:
> >>> > Before you make your own custom solution, you might want to read up
> on
> >>> > Javagroup.  It might not be a problem to use it in your environment.
> >>> >
> >>> > The main page starts off with this:
> >>> >
> >>> > http://www.jgroups.org/
> >>> > ==================================
> >>> > JGroups is a toolkit for reliable multicast communication.
> >>> > (Note that this doesn't necessarily mean IP Multicast, JGroups can
> >>> > also use transports such as TCP).
> >>> >
> >>> > [...]
> >>> >
> >>> > JGroups comes with a number of protocols (but anyone can write their
> >>> > own), for example
> >>> >    * Transport protocols: UDP (IP Multicast), TCP, JMS
> >>> >
> >>> > ==================================
> >>> >
> >>> > So even if the TCP version doesn't do what you need, you might find
> it
> >>> > easier to write your own Jgroup protocol than to write your own
> >>> > cayenne event bridge.  It's more likely to be documented and there
> >>> > will be more examples/end users to ask questions of.  There might
> even
> >>> > be a tomcat shared session protocol out there somewhere.
> >>> >
> >>> >
> >>> > On Wed, Jul 29, 2009 at 4:16 PM, Tobias
> >>> > Schoessler<to...@gmail.com> wrote:
> >>> >> well i am reading this from the documentation:
> >>> >>
> >>> >> "... At the minimum, JMS setup requires a JMS server running, and
> >>> subjects
> >>> >> for each of the DataDomains to be configured. JavaGroups is
> >>> peer-to-peer
> >>> >> library that is embedded into applications. Default configuration
> >>> provided
> >>> >> by CayenneModeler will work out of the box, provided that IP
> multicast
> >>> is
> >>> >> enabled on the network."
> >>> >>
> >>> >> for the JMS solution the JMS server setup is a problem
> >>> >> for the JavaGroups setup the "IP multicast is enabled on the
> network."
> >>>  is a
> >>> >> problem
> >>> >>
> >>> >> so  for the custom tranport mechanism that you mentioned I stumbled
> >>> upon
> >>> >> this here
> >>> >>
> >>> >>
> >>>
> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
> >>> >>
> >>> >> which seems to describe cross context data sharing on tomcat web
> >>> contexts
> >>> >>
> >>> >> but is there any code to look at to see how a custom transport
> >>> mechanism can
> >>> >> be setup?
> >>> >>
> >>> >> Tobias
> >>> >>
> >>> >>
> >>> >> On Wed, Jul 29, 2009 at 8:28 PM, Mike Kienenberger <
> mkienenb@gmail.com
> >>> >wrote:
> >>> >>
> >>> >>> I've never set it up, but it's easily configurable.
> >>> >>>
> >>> >>> If you don't like the javagroups or JMS methodologies, you can
> define
> >>> >>> your own -- I don't know what tomcat app-data-sharing ability is
> >>> >>> available -- it probably depends on the container, but I don't
> >>> >>> remember reading about any in the past.
> >>> >>>
> >>> >>> However, the docs seem to indicate that using Javagroups is pretty
> >>> >>> painless with no external configuration to deal with.
> >>> >>>
> >>> >>> I have a Cayenne 1.1.x application I wrote that used remote
> >>> >>> notification internally to broadcast events between sessions, so I
> >>> >>> know it's not difficult to set up and define your own event
> >>> >>> broadcaster.  My guess is that doing it for javagroups is pretty
> easy
> >>> >>> since it sounds like a matter of just filling in the forms on the
> >>> >>> modeler.
> >>> >>>
> >>> >>> On Wed, Jul 29, 2009 at 2:15 PM, Tobias
> >>> >>> Schoessler<to...@gmail.com> wrote:
> >>> >>> > Thanks Mike,
> >>> >>> >
> >>> >>> > so the answer is yes, this can only be done using remote
> >>> notification? is
> >>> >>> > this correct?
> >>> >>> >
> >>> >>> > Isn't there a way to share the cache among two web application
> >>> scopes
> >>> >>> > without going through the hassle of setting up remote
> notification?
> >>> >>> >
> >>> >>> > When the two webapps are running on the same physical machine,
> >>> inside the
> >>> >>> > same application server this seems overkill.
> >>> >>> >
> >>> >>> > Tobias
> >>> >>> >
> >>> >>> > On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <
> >>> mkienenb@gmail.com
> >>> >>> >wrote:
> >>> >>> >
> >>> >>> >> Yes,
> >>> >>> >>
> >>> >>> >> Here's a Cayenne 2.0 document on it:
> >>> >>> >>
> >>> >>> >>
> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
> >>> >>> >>
> >>> >>> >> For 3.0:
> >>> >>> >>
> >>> >>> >> http://cayenne.apache.org/doc/configuring-caching-behavior.html
> >>> >>> >>
> >>> >>> >> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
> >>> >>> >> Schoessler<to...@gmail.com> wrote:
> >>> >>> >> > Hi,
> >>> >>> >> >
> >>> >>> >> > is it possible to sync the cayenne cache of two web
> applications
> >>> >>> running
> >>> >>> >> in
> >>> >>> >> > the same tomcat?
> >>> >>> >> >
> >>> >>> >> > I observe one web app showing outdated data when the other is
> >>> >>> committing
> >>> >>> >> > updates. Both apps are using the same mapping configuration.
> >>> >>> >> >
> >>> >>> >> > Do I need to use remote notification for this?
> >>> >>> >> >
> >>> >>> >> > thanks
> >>> >>> >> >
> >>> >>> >> > Tobias
> >>> >>> >> >
> >>> >>> >>
> >>> >>> >
> >>> >>>
> >>> >>
> >>> >
> >>>
> >>
> >>
> >
>

Re: sync cayenne cache in two web apps

Posted by Mike Kienenberger <mk...@gmail.com>.
Inserts, deletes, updates, and invalidates, if I remember correctly.

On Thu, Jul 30, 2009 at 5:33 PM, Michael Gentry<mg...@masslight.net> wrote:
> Hi Tobias,
>
> I've not used the cache synchronization before, but I was under the
> impression that the main overhead is when inserts/updates/deletes are
> done, not when selects are done.  When you do an insert/update/delete,
> that information must be broadcast, but selects do not.  I'm sure
> someone will correct me if I am wrong on this.  :-)
>
> mrg
>
>
> On Thu, Jul 30, 2009 at 5:23 PM, Tobias
> Schoessler<to...@gmail.com> wrote:
>> So thank you for all the suggestions. The solution we finally ended up with
>> was the one Mike actually suggested intitially. We got our multicast ip,
>> dropped the latest Jgroups.jar into both webapps lib directories, selected
>> Jgroups as the Syncronisation mechanism in the cayenne modeller, used the
>> default jgroups udp.xml config file patched with our multicast ip address
>> and 'snapp' the contexts were synchronized. Very satisfying - Cayenne
>> rocks.! :)
>>
>> Before this I went down the route of trying to make cayenne use the global
>> JVM scope to store the shared cache. I moved the cayenne.jar up on the
>> tomcat shared lib directory, out of the two web app lib folders. This did
>> not work out well, I got stuck at the point where one web app worked fine
>> the other one threw class cast exception on the mapping objects saying it
>> cannot cast the types on itself. I assume this is due to the fact that both
>> webapps had their own copies of the mapping classes. I tried moving them up
>> into the shared tomcat lib aswell, but  then they could not see the web app
>> specific classes anymore. So anyway I am happy with our Jgroups solution
>> now.
>>
>> The documentation reads lthis setup has some overhead. Does anybody have
>> experience/numbers how much performance you loose when using jgroups
>> syncronised caches compared to local cache?
>>
>> thanks again everyone.
>>
>> On Thu, Jul 30, 2009 at 10:47 AM, Tobias Schoessler <
>> tobias.schoessler@gmail.com> wrote:
>>
>>> Thanks everyone for the posts.
>>>
>>> @Mike, I am still not convinced that using the Remote Notification Feature
>>> is really nessecary here. After all, there seems to be a JVM shared between
>>> webapps in Tomcat and the article posted seems to proof that there is a
>>> possiblity to share information between the webapps on a JVM level. So I
>>> think that using Remote Notification, which I understand to be designed for
>>> Cross JVM notification creates too much overhead.
>>>
>>> You mentioned the possibility of sharing the DataContext between the
>>> webapps. I think I have to explore this possibility first, as this would
>>> have less overhead compared to the notification based solution.
>>> Currently I am using the
>>> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(request.getSession())
>>> to obtain my DataContexts per request.
>>> If I could change the scope the DataContexts are stored to cross web app
>>> scope instead of session scope I could share the DataContexts between the
>>> two web apps. Assuming that I can setup the two webapps to share the same
>>> session Ids as described in the article.
>>>
>>> This might be a no go for me as the two contexts use different
>>> authentication realms - I have to check this. But even then wouldn't it be
>>> possbile to configure the cayenne shared cache to use this cross web context
>>> scope for its shared cache. Then I could use
>>> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(session) in the
>>> two web apps transparently and cayenne would refresh the DataContext from
>>> this shared cache in the background. Could somebody point me to where this
>>> shared cayenne cache is configured to have its scope? I assume it uses JVM
>>> static scope?
>>>
>>> @Malcolm, thanks for suggesting this alternative. If I understand you
>>> correctly you suggest to switch off the cayenne cache alltogether and use
>>> the jsptag based caching of the OScache project? The problem with this is
>>> that not all my responses are generated from jsptags. I have many ajax
>>> requests generating json responses without bothering the jsp container.
>>>
>>> Tobias
>>>
>>>
>>> On Thu, Jul 30, 2009 at 3:00 AM, Malcolm Edgar <ma...@gmail.com>wrote:
>>>
>>>> You can also use OSCache with Cayenne and have the cached queries
>>>> expire frequently, i.e. after 30 seconds
>>>>
>>>> regards Malcolm Edgar
>>>>
>>>> On Thu, Jul 30, 2009 at 6:36 AM, Mike Kienenberger<mk...@gmail.com>
>>>> wrote:
>>>> > Before you make your own custom solution, you might want to read up on
>>>> > Javagroup.  It might not be a problem to use it in your environment.
>>>> >
>>>> > The main page starts off with this:
>>>> >
>>>> > http://www.jgroups.org/
>>>> > ==================================
>>>> > JGroups is a toolkit for reliable multicast communication.
>>>> > (Note that this doesn't necessarily mean IP Multicast, JGroups can
>>>> > also use transports such as TCP).
>>>> >
>>>> > [...]
>>>> >
>>>> > JGroups comes with a number of protocols (but anyone can write their
>>>> > own), for example
>>>> >    * Transport protocols: UDP (IP Multicast), TCP, JMS
>>>> >
>>>> > ==================================
>>>> >
>>>> > So even if the TCP version doesn't do what you need, you might find it
>>>> > easier to write your own Jgroup protocol than to write your own
>>>> > cayenne event bridge.  It's more likely to be documented and there
>>>> > will be more examples/end users to ask questions of.  There might even
>>>> > be a tomcat shared session protocol out there somewhere.
>>>> >
>>>> >
>>>> > On Wed, Jul 29, 2009 at 4:16 PM, Tobias
>>>> > Schoessler<to...@gmail.com> wrote:
>>>> >> well i am reading this from the documentation:
>>>> >>
>>>> >> "... At the minimum, JMS setup requires a JMS server running, and
>>>> subjects
>>>> >> for each of the DataDomains to be configured. JavaGroups is
>>>> peer-to-peer
>>>> >> library that is embedded into applications. Default configuration
>>>> provided
>>>> >> by CayenneModeler will work out of the box, provided that IP multicast
>>>> is
>>>> >> enabled on the network."
>>>> >>
>>>> >> for the JMS solution the JMS server setup is a problem
>>>> >> for the JavaGroups setup the "IP multicast is enabled on the network."
>>>>  is a
>>>> >> problem
>>>> >>
>>>> >> so  for the custom tranport mechanism that you mentioned I stumbled
>>>> upon
>>>> >> this here
>>>> >>
>>>> >>
>>>> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>>>> >>
>>>> >> which seems to describe cross context data sharing on tomcat web
>>>> contexts
>>>> >>
>>>> >> but is there any code to look at to see how a custom transport
>>>> mechanism can
>>>> >> be setup?
>>>> >>
>>>> >> Tobias
>>>> >>
>>>> >>
>>>> >> On Wed, Jul 29, 2009 at 8:28 PM, Mike Kienenberger <mkienenb@gmail.com
>>>> >wrote:
>>>> >>
>>>> >>> I've never set it up, but it's easily configurable.
>>>> >>>
>>>> >>> If you don't like the javagroups or JMS methodologies, you can define
>>>> >>> your own -- I don't know what tomcat app-data-sharing ability is
>>>> >>> available -- it probably depends on the container, but I don't
>>>> >>> remember reading about any in the past.
>>>> >>>
>>>> >>> However, the docs seem to indicate that using Javagroups is pretty
>>>> >>> painless with no external configuration to deal with.
>>>> >>>
>>>> >>> I have a Cayenne 1.1.x application I wrote that used remote
>>>> >>> notification internally to broadcast events between sessions, so I
>>>> >>> know it's not difficult to set up and define your own event
>>>> >>> broadcaster.  My guess is that doing it for javagroups is pretty easy
>>>> >>> since it sounds like a matter of just filling in the forms on the
>>>> >>> modeler.
>>>> >>>
>>>> >>> On Wed, Jul 29, 2009 at 2:15 PM, Tobias
>>>> >>> Schoessler<to...@gmail.com> wrote:
>>>> >>> > Thanks Mike,
>>>> >>> >
>>>> >>> > so the answer is yes, this can only be done using remote
>>>> notification? is
>>>> >>> > this correct?
>>>> >>> >
>>>> >>> > Isn't there a way to share the cache among two web application
>>>> scopes
>>>> >>> > without going through the hassle of setting up remote notification?
>>>> >>> >
>>>> >>> > When the two webapps are running on the same physical machine,
>>>> inside the
>>>> >>> > same application server this seems overkill.
>>>> >>> >
>>>> >>> > Tobias
>>>> >>> >
>>>> >>> > On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <
>>>> mkienenb@gmail.com
>>>> >>> >wrote:
>>>> >>> >
>>>> >>> >> Yes,
>>>> >>> >>
>>>> >>> >> Here's a Cayenne 2.0 document on it:
>>>> >>> >>
>>>> >>> >> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
>>>> >>> >>
>>>> >>> >> For 3.0:
>>>> >>> >>
>>>> >>> >> http://cayenne.apache.org/doc/configuring-caching-behavior.html
>>>> >>> >>
>>>> >>> >> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
>>>> >>> >> Schoessler<to...@gmail.com> wrote:
>>>> >>> >> > Hi,
>>>> >>> >> >
>>>> >>> >> > is it possible to sync the cayenne cache of two web applications
>>>> >>> running
>>>> >>> >> in
>>>> >>> >> > the same tomcat?
>>>> >>> >> >
>>>> >>> >> > I observe one web app showing outdated data when the other is
>>>> >>> committing
>>>> >>> >> > updates. Both apps are using the same mapping configuration.
>>>> >>> >> >
>>>> >>> >> > Do I need to use remote notification for this?
>>>> >>> >> >
>>>> >>> >> > thanks
>>>> >>> >> >
>>>> >>> >> > Tobias
>>>> >>> >> >
>>>> >>> >>
>>>> >>> >
>>>> >>>
>>>> >>
>>>> >
>>>>
>>>
>>>
>>
>

Re: sync cayenne cache in two web apps

Posted by Michael Gentry <mg...@masslight.net>.
Hi Tobias,

I've not used the cache synchronization before, but I was under the
impression that the main overhead is when inserts/updates/deletes are
done, not when selects are done.  When you do an insert/update/delete,
that information must be broadcast, but selects do not.  I'm sure
someone will correct me if I am wrong on this.  :-)

mrg


On Thu, Jul 30, 2009 at 5:23 PM, Tobias
Schoessler<to...@gmail.com> wrote:
> So thank you for all the suggestions. The solution we finally ended up with
> was the one Mike actually suggested intitially. We got our multicast ip,
> dropped the latest Jgroups.jar into both webapps lib directories, selected
> Jgroups as the Syncronisation mechanism in the cayenne modeller, used the
> default jgroups udp.xml config file patched with our multicast ip address
> and 'snapp' the contexts were synchronized. Very satisfying - Cayenne
> rocks.! :)
>
> Before this I went down the route of trying to make cayenne use the global
> JVM scope to store the shared cache. I moved the cayenne.jar up on the
> tomcat shared lib directory, out of the two web app lib folders. This did
> not work out well, I got stuck at the point where one web app worked fine
> the other one threw class cast exception on the mapping objects saying it
> cannot cast the types on itself. I assume this is due to the fact that both
> webapps had their own copies of the mapping classes. I tried moving them up
> into the shared tomcat lib aswell, but  then they could not see the web app
> specific classes anymore. So anyway I am happy with our Jgroups solution
> now.
>
> The documentation reads lthis setup has some overhead. Does anybody have
> experience/numbers how much performance you loose when using jgroups
> syncronised caches compared to local cache?
>
> thanks again everyone.
>
> On Thu, Jul 30, 2009 at 10:47 AM, Tobias Schoessler <
> tobias.schoessler@gmail.com> wrote:
>
>> Thanks everyone for the posts.
>>
>> @Mike, I am still not convinced that using the Remote Notification Feature
>> is really nessecary here. After all, there seems to be a JVM shared between
>> webapps in Tomcat and the article posted seems to proof that there is a
>> possiblity to share information between the webapps on a JVM level. So I
>> think that using Remote Notification, which I understand to be designed for
>> Cross JVM notification creates too much overhead.
>>
>> You mentioned the possibility of sharing the DataContext between the
>> webapps. I think I have to explore this possibility first, as this would
>> have less overhead compared to the notification based solution.
>> Currently I am using the
>> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(request.getSession())
>> to obtain my DataContexts per request.
>> If I could change the scope the DataContexts are stored to cross web app
>> scope instead of session scope I could share the DataContexts between the
>> two web apps. Assuming that I can setup the two webapps to share the same
>> session Ids as described in the article.
>>
>> This might be a no go for me as the two contexts use different
>> authentication realms - I have to check this. But even then wouldn't it be
>> possbile to configure the cayenne shared cache to use this cross web context
>> scope for its shared cache. Then I could use
>> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(session) in the
>> two web apps transparently and cayenne would refresh the DataContext from
>> this shared cache in the background. Could somebody point me to where this
>> shared cayenne cache is configured to have its scope? I assume it uses JVM
>> static scope?
>>
>> @Malcolm, thanks for suggesting this alternative. If I understand you
>> correctly you suggest to switch off the cayenne cache alltogether and use
>> the jsptag based caching of the OScache project? The problem with this is
>> that not all my responses are generated from jsptags. I have many ajax
>> requests generating json responses without bothering the jsp container.
>>
>> Tobias
>>
>>
>> On Thu, Jul 30, 2009 at 3:00 AM, Malcolm Edgar <ma...@gmail.com>wrote:
>>
>>> You can also use OSCache with Cayenne and have the cached queries
>>> expire frequently, i.e. after 30 seconds
>>>
>>> regards Malcolm Edgar
>>>
>>> On Thu, Jul 30, 2009 at 6:36 AM, Mike Kienenberger<mk...@gmail.com>
>>> wrote:
>>> > Before you make your own custom solution, you might want to read up on
>>> > Javagroup.  It might not be a problem to use it in your environment.
>>> >
>>> > The main page starts off with this:
>>> >
>>> > http://www.jgroups.org/
>>> > ==================================
>>> > JGroups is a toolkit for reliable multicast communication.
>>> > (Note that this doesn't necessarily mean IP Multicast, JGroups can
>>> > also use transports such as TCP).
>>> >
>>> > [...]
>>> >
>>> > JGroups comes with a number of protocols (but anyone can write their
>>> > own), for example
>>> >    * Transport protocols: UDP (IP Multicast), TCP, JMS
>>> >
>>> > ==================================
>>> >
>>> > So even if the TCP version doesn't do what you need, you might find it
>>> > easier to write your own Jgroup protocol than to write your own
>>> > cayenne event bridge.  It's more likely to be documented and there
>>> > will be more examples/end users to ask questions of.  There might even
>>> > be a tomcat shared session protocol out there somewhere.
>>> >
>>> >
>>> > On Wed, Jul 29, 2009 at 4:16 PM, Tobias
>>> > Schoessler<to...@gmail.com> wrote:
>>> >> well i am reading this from the documentation:
>>> >>
>>> >> "... At the minimum, JMS setup requires a JMS server running, and
>>> subjects
>>> >> for each of the DataDomains to be configured. JavaGroups is
>>> peer-to-peer
>>> >> library that is embedded into applications. Default configuration
>>> provided
>>> >> by CayenneModeler will work out of the box, provided that IP multicast
>>> is
>>> >> enabled on the network."
>>> >>
>>> >> for the JMS solution the JMS server setup is a problem
>>> >> for the JavaGroups setup the "IP multicast is enabled on the network."
>>>  is a
>>> >> problem
>>> >>
>>> >> so  for the custom tranport mechanism that you mentioned I stumbled
>>> upon
>>> >> this here
>>> >>
>>> >>
>>> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>>> >>
>>> >> which seems to describe cross context data sharing on tomcat web
>>> contexts
>>> >>
>>> >> but is there any code to look at to see how a custom transport
>>> mechanism can
>>> >> be setup?
>>> >>
>>> >> Tobias
>>> >>
>>> >>
>>> >> On Wed, Jul 29, 2009 at 8:28 PM, Mike Kienenberger <mkienenb@gmail.com
>>> >wrote:
>>> >>
>>> >>> I've never set it up, but it's easily configurable.
>>> >>>
>>> >>> If you don't like the javagroups or JMS methodologies, you can define
>>> >>> your own -- I don't know what tomcat app-data-sharing ability is
>>> >>> available -- it probably depends on the container, but I don't
>>> >>> remember reading about any in the past.
>>> >>>
>>> >>> However, the docs seem to indicate that using Javagroups is pretty
>>> >>> painless with no external configuration to deal with.
>>> >>>
>>> >>> I have a Cayenne 1.1.x application I wrote that used remote
>>> >>> notification internally to broadcast events between sessions, so I
>>> >>> know it's not difficult to set up and define your own event
>>> >>> broadcaster.  My guess is that doing it for javagroups is pretty easy
>>> >>> since it sounds like a matter of just filling in the forms on the
>>> >>> modeler.
>>> >>>
>>> >>> On Wed, Jul 29, 2009 at 2:15 PM, Tobias
>>> >>> Schoessler<to...@gmail.com> wrote:
>>> >>> > Thanks Mike,
>>> >>> >
>>> >>> > so the answer is yes, this can only be done using remote
>>> notification? is
>>> >>> > this correct?
>>> >>> >
>>> >>> > Isn't there a way to share the cache among two web application
>>> scopes
>>> >>> > without going through the hassle of setting up remote notification?
>>> >>> >
>>> >>> > When the two webapps are running on the same physical machine,
>>> inside the
>>> >>> > same application server this seems overkill.
>>> >>> >
>>> >>> > Tobias
>>> >>> >
>>> >>> > On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <
>>> mkienenb@gmail.com
>>> >>> >wrote:
>>> >>> >
>>> >>> >> Yes,
>>> >>> >>
>>> >>> >> Here's a Cayenne 2.0 document on it:
>>> >>> >>
>>> >>> >> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
>>> >>> >>
>>> >>> >> For 3.0:
>>> >>> >>
>>> >>> >> http://cayenne.apache.org/doc/configuring-caching-behavior.html
>>> >>> >>
>>> >>> >> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
>>> >>> >> Schoessler<to...@gmail.com> wrote:
>>> >>> >> > Hi,
>>> >>> >> >
>>> >>> >> > is it possible to sync the cayenne cache of two web applications
>>> >>> running
>>> >>> >> in
>>> >>> >> > the same tomcat?
>>> >>> >> >
>>> >>> >> > I observe one web app showing outdated data when the other is
>>> >>> committing
>>> >>> >> > updates. Both apps are using the same mapping configuration.
>>> >>> >> >
>>> >>> >> > Do I need to use remote notification for this?
>>> >>> >> >
>>> >>> >> > thanks
>>> >>> >> >
>>> >>> >> > Tobias
>>> >>> >> >
>>> >>> >>
>>> >>> >
>>> >>>
>>> >>
>>> >
>>>
>>
>>
>

Re: sync cayenne cache in two web apps

Posted by Tobias Schoessler <to...@gmail.com>.
So thank you for all the suggestions. The solution we finally ended up with
was the one Mike actually suggested intitially. We got our multicast ip,
dropped the latest Jgroups.jar into both webapps lib directories, selected
Jgroups as the Syncronisation mechanism in the cayenne modeller, used the
default jgroups udp.xml config file patched with our multicast ip address
and 'snapp' the contexts were synchronized. Very satisfying - Cayenne
rocks.! :)

Before this I went down the route of trying to make cayenne use the global
JVM scope to store the shared cache. I moved the cayenne.jar up on the
tomcat shared lib directory, out of the two web app lib folders. This did
not work out well, I got stuck at the point where one web app worked fine
the other one threw class cast exception on the mapping objects saying it
cannot cast the types on itself. I assume this is due to the fact that both
webapps had their own copies of the mapping classes. I tried moving them up
into the shared tomcat lib aswell, but  then they could not see the web app
specific classes anymore. So anyway I am happy with our Jgroups solution
now.

The documentation reads lthis setup has some overhead. Does anybody have
experience/numbers how much performance you loose when using jgroups
syncronised caches compared to local cache?

thanks again everyone.

On Thu, Jul 30, 2009 at 10:47 AM, Tobias Schoessler <
tobias.schoessler@gmail.com> wrote:

> Thanks everyone for the posts.
>
> @Mike, I am still not convinced that using the Remote Notification Feature
> is really nessecary here. After all, there seems to be a JVM shared between
> webapps in Tomcat and the article posted seems to proof that there is a
> possiblity to share information between the webapps on a JVM level. So I
> think that using Remote Notification, which I understand to be designed for
> Cross JVM notification creates too much overhead.
>
> You mentioned the possibility of sharing the DataContext between the
> webapps. I think I have to explore this possibility first, as this would
> have less overhead compared to the notification based solution.
> Currently I am using the
> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(request.getSession())
> to obtain my DataContexts per request.
> If I could change the scope the DataContexts are stored to cross web app
> scope instead of session scope I could share the DataContexts between the
> two web apps. Assuming that I can setup the two webapps to share the same
> session Ids as described in the article.
>
> This might be a no go for me as the two contexts use different
> authentication realms - I have to check this. But even then wouldn't it be
> possbile to configure the cayenne shared cache to use this cross web context
> scope for its shared cache. Then I could use
> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(session) in the
> two web apps transparently and cayenne would refresh the DataContext from
> this shared cache in the background. Could somebody point me to where this
> shared cayenne cache is configured to have its scope? I assume it uses JVM
> static scope?
>
> @Malcolm, thanks for suggesting this alternative. If I understand you
> correctly you suggest to switch off the cayenne cache alltogether and use
> the jsptag based caching of the OScache project? The problem with this is
> that not all my responses are generated from jsptags. I have many ajax
> requests generating json responses without bothering the jsp container.
>
> Tobias
>
>
> On Thu, Jul 30, 2009 at 3:00 AM, Malcolm Edgar <ma...@gmail.com>wrote:
>
>> You can also use OSCache with Cayenne and have the cached queries
>> expire frequently, i.e. after 30 seconds
>>
>> regards Malcolm Edgar
>>
>> On Thu, Jul 30, 2009 at 6:36 AM, Mike Kienenberger<mk...@gmail.com>
>> wrote:
>> > Before you make your own custom solution, you might want to read up on
>> > Javagroup.  It might not be a problem to use it in your environment.
>> >
>> > The main page starts off with this:
>> >
>> > http://www.jgroups.org/
>> > ==================================
>> > JGroups is a toolkit for reliable multicast communication.
>> > (Note that this doesn't necessarily mean IP Multicast, JGroups can
>> > also use transports such as TCP).
>> >
>> > [...]
>> >
>> > JGroups comes with a number of protocols (but anyone can write their
>> > own), for example
>> >    * Transport protocols: UDP (IP Multicast), TCP, JMS
>> >
>> > ==================================
>> >
>> > So even if the TCP version doesn't do what you need, you might find it
>> > easier to write your own Jgroup protocol than to write your own
>> > cayenne event bridge.  It's more likely to be documented and there
>> > will be more examples/end users to ask questions of.  There might even
>> > be a tomcat shared session protocol out there somewhere.
>> >
>> >
>> > On Wed, Jul 29, 2009 at 4:16 PM, Tobias
>> > Schoessler<to...@gmail.com> wrote:
>> >> well i am reading this from the documentation:
>> >>
>> >> "... At the minimum, JMS setup requires a JMS server running, and
>> subjects
>> >> for each of the DataDomains to be configured. JavaGroups is
>> peer-to-peer
>> >> library that is embedded into applications. Default configuration
>> provided
>> >> by CayenneModeler will work out of the box, provided that IP multicast
>> is
>> >> enabled on the network."
>> >>
>> >> for the JMS solution the JMS server setup is a problem
>> >> for the JavaGroups setup the "IP multicast is enabled on the network."
>>  is a
>> >> problem
>> >>
>> >> so  for the custom tranport mechanism that you mentioned I stumbled
>> upon
>> >> this here
>> >>
>> >>
>> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>> >>
>> >> which seems to describe cross context data sharing on tomcat web
>> contexts
>> >>
>> >> but is there any code to look at to see how a custom transport
>> mechanism can
>> >> be setup?
>> >>
>> >> Tobias
>> >>
>> >>
>> >> On Wed, Jul 29, 2009 at 8:28 PM, Mike Kienenberger <mkienenb@gmail.com
>> >wrote:
>> >>
>> >>> I've never set it up, but it's easily configurable.
>> >>>
>> >>> If you don't like the javagroups or JMS methodologies, you can define
>> >>> your own -- I don't know what tomcat app-data-sharing ability is
>> >>> available -- it probably depends on the container, but I don't
>> >>> remember reading about any in the past.
>> >>>
>> >>> However, the docs seem to indicate that using Javagroups is pretty
>> >>> painless with no external configuration to deal with.
>> >>>
>> >>> I have a Cayenne 1.1.x application I wrote that used remote
>> >>> notification internally to broadcast events between sessions, so I
>> >>> know it's not difficult to set up and define your own event
>> >>> broadcaster.  My guess is that doing it for javagroups is pretty easy
>> >>> since it sounds like a matter of just filling in the forms on the
>> >>> modeler.
>> >>>
>> >>> On Wed, Jul 29, 2009 at 2:15 PM, Tobias
>> >>> Schoessler<to...@gmail.com> wrote:
>> >>> > Thanks Mike,
>> >>> >
>> >>> > so the answer is yes, this can only be done using remote
>> notification? is
>> >>> > this correct?
>> >>> >
>> >>> > Isn't there a way to share the cache among two web application
>> scopes
>> >>> > without going through the hassle of setting up remote notification?
>> >>> >
>> >>> > When the two webapps are running on the same physical machine,
>> inside the
>> >>> > same application server this seems overkill.
>> >>> >
>> >>> > Tobias
>> >>> >
>> >>> > On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <
>> mkienenb@gmail.com
>> >>> >wrote:
>> >>> >
>> >>> >> Yes,
>> >>> >>
>> >>> >> Here's a Cayenne 2.0 document on it:
>> >>> >>
>> >>> >> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
>> >>> >>
>> >>> >> For 3.0:
>> >>> >>
>> >>> >> http://cayenne.apache.org/doc/configuring-caching-behavior.html
>> >>> >>
>> >>> >> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
>> >>> >> Schoessler<to...@gmail.com> wrote:
>> >>> >> > Hi,
>> >>> >> >
>> >>> >> > is it possible to sync the cayenne cache of two web applications
>> >>> running
>> >>> >> in
>> >>> >> > the same tomcat?
>> >>> >> >
>> >>> >> > I observe one web app showing outdated data when the other is
>> >>> committing
>> >>> >> > updates. Both apps are using the same mapping configuration.
>> >>> >> >
>> >>> >> > Do I need to use remote notification for this?
>> >>> >> >
>> >>> >> > thanks
>> >>> >> >
>> >>> >> > Tobias
>> >>> >> >
>> >>> >>
>> >>> >
>> >>>
>> >>
>> >
>>
>
>

Re: sync cayenne cache in two web apps

Posted by Malcolm Edgar <ma...@gmail.com>.
On Thu, Jul 30, 2009 at 6:47 PM, Tobias
Schoessler<to...@gmail.com> wrote:
> Thanks everyone for the posts.
>
> @Mike, I am still not convinced that using the Remote Notification Feature
> is really nessecary here. After all, there seems to be a JVM shared between
> webapps in Tomcat and the article posted seems to proof that there is a
> possiblity to share information between the webapps on a JVM level. So I
> think that using Remote Notification, which I understand to be designed for
> Cross JVM notification creates too much overhead.
>
> You mentioned the possibility of sharing the DataContext between the
> webapps. I think I have to explore this possibility first, as this would
> have less overhead compared to the notification based solution.
> Currently I am using the
> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(request.getSession())
> to obtain my DataContexts per request.
> If I could change the scope the DataContexts are stored to cross web app
> scope instead of session scope I could share the DataContexts between the
> two web apps. Assuming that I can setup the two webapps to share the same
> session Ids as described in the article.
>
> This might be a no go for me as the two contexts use different
> authentication realms - I have to check this. But even then wouldn't it be
> possbile to configure the cayenne shared cache to use this cross web context
> scope for its shared cache. Then I could use
> org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(session) in the
> two web apps transparently and cayenne would refresh the DataContext from
> this shared cache in the background. Could somebody point me to where this
> shared cayenne cache is configured to have its scope? I assume it uses JVM
> static scope?
>
> @Malcolm, thanks for suggesting this alternative. If I understand you
> correctly you suggest to switch off the cayenne cache alltogether and use
> the jsptag based caching of the OScache project? The problem with this is
> that not all my responses are generated from jsptags. I have many ajax
> requests generating json responses without bothering the jsp container.

JSP... the horror. No we do this all at the DAO level.

We initialize the Cayenne DataDomain to use OSCache as the caching factory

DataDomain dataDomain = Configuration.getSharedConfiguration().getDomain();
dataDomain.setQueryCacheFactory(new OSQueryCacheFactory());

Then in our SelectQuery we may set the query to use a JVM shared cache

query.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);

With the oscache.properties we will expire all query caches in 30
seconds. This saves the database from being hammered by frequent
request.

cache.capacity=5000
cache.algorithm=com.opensymphony.oscache.base.algorithm.LRUCache

# Cayenne specific properties:

# Default refresh period in seconds
# (used for all cache groups not explicitly overriding it here)
cayenne.default.refresh = 30

As for your JSPs you can upgrade to Click and Velocity :)

regards Malcolm Edgar

> Tobias
>
> On Thu, Jul 30, 2009 at 3:00 AM, Malcolm Edgar <ma...@gmail.com>wrote:
>
>> You can also use OSCache with Cayenne and have the cached queries
>> expire frequently, i.e. after 30 seconds
>>
>> regards Malcolm Edgar
>>
>> On Thu, Jul 30, 2009 at 6:36 AM, Mike Kienenberger<mk...@gmail.com>
>> wrote:
>> > Before you make your own custom solution, you might want to read up on
>> > Javagroup.  It might not be a problem to use it in your environment.
>> >
>> > The main page starts off with this:
>> >
>> > http://www.jgroups.org/
>> > ==================================
>> > JGroups is a toolkit for reliable multicast communication.
>> > (Note that this doesn't necessarily mean IP Multicast, JGroups can
>> > also use transports such as TCP).
>> >
>> > [...]
>> >
>> > JGroups comes with a number of protocols (but anyone can write their
>> > own), for example
>> >    * Transport protocols: UDP (IP Multicast), TCP, JMS
>> >
>> > ==================================
>> >
>> > So even if the TCP version doesn't do what you need, you might find it
>> > easier to write your own Jgroup protocol than to write your own
>> > cayenne event bridge.  It's more likely to be documented and there
>> > will be more examples/end users to ask questions of.  There might even
>> > be a tomcat shared session protocol out there somewhere.
>> >
>> >
>> > On Wed, Jul 29, 2009 at 4:16 PM, Tobias
>> > Schoessler<to...@gmail.com> wrote:
>> >> well i am reading this from the documentation:
>> >>
>> >> "... At the minimum, JMS setup requires a JMS server running, and
>> subjects
>> >> for each of the DataDomains to be configured. JavaGroups is peer-to-peer
>> >> library that is embedded into applications. Default configuration
>> provided
>> >> by CayenneModeler will work out of the box, provided that IP multicast
>> is
>> >> enabled on the network."
>> >>
>> >> for the JMS solution the JMS server setup is a problem
>> >> for the JavaGroups setup the "IP multicast is enabled on the network."
>>  is a
>> >> problem
>> >>
>> >> so  for the custom tranport mechanism that you mentioned I stumbled upon
>> >> this here
>> >>
>> >>
>> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>> >>
>> >> which seems to describe cross context data sharing on tomcat web
>> contexts
>> >>
>> >> but is there any code to look at to see how a custom transport mechanism
>> can
>> >> be setup?
>> >>
>> >> Tobias
>> >>
>> >>
>> >> On Wed, Jul 29, 2009 at 8:28 PM, Mike Kienenberger <mkienenb@gmail.com
>> >wrote:
>> >>
>> >>> I've never set it up, but it's easily configurable.
>> >>>
>> >>> If you don't like the javagroups or JMS methodologies, you can define
>> >>> your own -- I don't know what tomcat app-data-sharing ability is
>> >>> available -- it probably depends on the container, but I don't
>> >>> remember reading about any in the past.
>> >>>
>> >>> However, the docs seem to indicate that using Javagroups is pretty
>> >>> painless with no external configuration to deal with.
>> >>>
>> >>> I have a Cayenne 1.1.x application I wrote that used remote
>> >>> notification internally to broadcast events between sessions, so I
>> >>> know it's not difficult to set up and define your own event
>> >>> broadcaster.  My guess is that doing it for javagroups is pretty easy
>> >>> since it sounds like a matter of just filling in the forms on the
>> >>> modeler.
>> >>>
>> >>> On Wed, Jul 29, 2009 at 2:15 PM, Tobias
>> >>> Schoessler<to...@gmail.com> wrote:
>> >>> > Thanks Mike,
>> >>> >
>> >>> > so the answer is yes, this can only be done using remote
>> notification? is
>> >>> > this correct?
>> >>> >
>> >>> > Isn't there a way to share the cache among two web application scopes
>> >>> > without going through the hassle of setting up remote notification?
>> >>> >
>> >>> > When the two webapps are running on the same physical machine, inside
>> the
>> >>> > same application server this seems overkill.
>> >>> >
>> >>> > Tobias
>> >>> >
>> >>> > On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <
>> mkienenb@gmail.com
>> >>> >wrote:
>> >>> >
>> >>> >> Yes,
>> >>> >>
>> >>> >> Here's a Cayenne 2.0 document on it:
>> >>> >>
>> >>> >> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
>> >>> >>
>> >>> >> For 3.0:
>> >>> >>
>> >>> >> http://cayenne.apache.org/doc/configuring-caching-behavior.html
>> >>> >>
>> >>> >> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
>> >>> >> Schoessler<to...@gmail.com> wrote:
>> >>> >> > Hi,
>> >>> >> >
>> >>> >> > is it possible to sync the cayenne cache of two web applications
>> >>> running
>> >>> >> in
>> >>> >> > the same tomcat?
>> >>> >> >
>> >>> >> > I observe one web app showing outdated data when the other is
>> >>> committing
>> >>> >> > updates. Both apps are using the same mapping configuration.
>> >>> >> >
>> >>> >> > Do I need to use remote notification for this?
>> >>> >> >
>> >>> >> > thanks
>> >>> >> >
>> >>> >> > Tobias
>> >>> >> >
>> >>> >>
>> >>> >
>> >>>
>> >>
>> >
>>
>

Re: sync cayenne cache in two web apps

Posted by Tobias Schoessler <to...@gmail.com>.
Thanks everyone for the posts.

@Mike, I am still not convinced that using the Remote Notification Feature
is really nessecary here. After all, there seems to be a JVM shared between
webapps in Tomcat and the article posted seems to proof that there is a
possiblity to share information between the webapps on a JVM level. So I
think that using Remote Notification, which I understand to be designed for
Cross JVM notification creates too much overhead.

You mentioned the possibility of sharing the DataContext between the
webapps. I think I have to explore this possibility first, as this would
have less overhead compared to the notification based solution.
Currently I am using the
org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(request.getSession())
to obtain my DataContexts per request.
If I could change the scope the DataContexts are stored to cross web app
scope instead of session scope I could share the DataContexts between the
two web apps. Assuming that I can setup the two webapps to share the same
session Ids as described in the article.

This might be a no go for me as the two contexts use different
authentication realms - I have to check this. But even then wouldn't it be
possbile to configure the cayenne shared cache to use this cross web context
scope for its shared cache. Then I could use
org.objectstyle.cayenne.conf.ServletUtil.getSessionContext(session) in the
two web apps transparently and cayenne would refresh the DataContext from
this shared cache in the background. Could somebody point me to where this
shared cayenne cache is configured to have its scope? I assume it uses JVM
static scope?

@Malcolm, thanks for suggesting this alternative. If I understand you
correctly you suggest to switch off the cayenne cache alltogether and use
the jsptag based caching of the OScache project? The problem with this is
that not all my responses are generated from jsptags. I have many ajax
requests generating json responses without bothering the jsp container.

Tobias

On Thu, Jul 30, 2009 at 3:00 AM, Malcolm Edgar <ma...@gmail.com>wrote:

> You can also use OSCache with Cayenne and have the cached queries
> expire frequently, i.e. after 30 seconds
>
> regards Malcolm Edgar
>
> On Thu, Jul 30, 2009 at 6:36 AM, Mike Kienenberger<mk...@gmail.com>
> wrote:
> > Before you make your own custom solution, you might want to read up on
> > Javagroup.  It might not be a problem to use it in your environment.
> >
> > The main page starts off with this:
> >
> > http://www.jgroups.org/
> > ==================================
> > JGroups is a toolkit for reliable multicast communication.
> > (Note that this doesn't necessarily mean IP Multicast, JGroups can
> > also use transports such as TCP).
> >
> > [...]
> >
> > JGroups comes with a number of protocols (but anyone can write their
> > own), for example
> >    * Transport protocols: UDP (IP Multicast), TCP, JMS
> >
> > ==================================
> >
> > So even if the TCP version doesn't do what you need, you might find it
> > easier to write your own Jgroup protocol than to write your own
> > cayenne event bridge.  It's more likely to be documented and there
> > will be more examples/end users to ask questions of.  There might even
> > be a tomcat shared session protocol out there somewhere.
> >
> >
> > On Wed, Jul 29, 2009 at 4:16 PM, Tobias
> > Schoessler<to...@gmail.com> wrote:
> >> well i am reading this from the documentation:
> >>
> >> "... At the minimum, JMS setup requires a JMS server running, and
> subjects
> >> for each of the DataDomains to be configured. JavaGroups is peer-to-peer
> >> library that is embedded into applications. Default configuration
> provided
> >> by CayenneModeler will work out of the box, provided that IP multicast
> is
> >> enabled on the network."
> >>
> >> for the JMS solution the JMS server setup is a problem
> >> for the JavaGroups setup the "IP multicast is enabled on the network."
>  is a
> >> problem
> >>
> >> so  for the custom tranport mechanism that you mentioned I stumbled upon
> >> this here
> >>
> >>
> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
> >>
> >> which seems to describe cross context data sharing on tomcat web
> contexts
> >>
> >> but is there any code to look at to see how a custom transport mechanism
> can
> >> be setup?
> >>
> >> Tobias
> >>
> >>
> >> On Wed, Jul 29, 2009 at 8:28 PM, Mike Kienenberger <mkienenb@gmail.com
> >wrote:
> >>
> >>> I've never set it up, but it's easily configurable.
> >>>
> >>> If you don't like the javagroups or JMS methodologies, you can define
> >>> your own -- I don't know what tomcat app-data-sharing ability is
> >>> available -- it probably depends on the container, but I don't
> >>> remember reading about any in the past.
> >>>
> >>> However, the docs seem to indicate that using Javagroups is pretty
> >>> painless with no external configuration to deal with.
> >>>
> >>> I have a Cayenne 1.1.x application I wrote that used remote
> >>> notification internally to broadcast events between sessions, so I
> >>> know it's not difficult to set up and define your own event
> >>> broadcaster.  My guess is that doing it for javagroups is pretty easy
> >>> since it sounds like a matter of just filling in the forms on the
> >>> modeler.
> >>>
> >>> On Wed, Jul 29, 2009 at 2:15 PM, Tobias
> >>> Schoessler<to...@gmail.com> wrote:
> >>> > Thanks Mike,
> >>> >
> >>> > so the answer is yes, this can only be done using remote
> notification? is
> >>> > this correct?
> >>> >
> >>> > Isn't there a way to share the cache among two web application scopes
> >>> > without going through the hassle of setting up remote notification?
> >>> >
> >>> > When the two webapps are running on the same physical machine, inside
> the
> >>> > same application server this seems overkill.
> >>> >
> >>> > Tobias
> >>> >
> >>> > On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <
> mkienenb@gmail.com
> >>> >wrote:
> >>> >
> >>> >> Yes,
> >>> >>
> >>> >> Here's a Cayenne 2.0 document on it:
> >>> >>
> >>> >> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
> >>> >>
> >>> >> For 3.0:
> >>> >>
> >>> >> http://cayenne.apache.org/doc/configuring-caching-behavior.html
> >>> >>
> >>> >> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
> >>> >> Schoessler<to...@gmail.com> wrote:
> >>> >> > Hi,
> >>> >> >
> >>> >> > is it possible to sync the cayenne cache of two web applications
> >>> running
> >>> >> in
> >>> >> > the same tomcat?
> >>> >> >
> >>> >> > I observe one web app showing outdated data when the other is
> >>> committing
> >>> >> > updates. Both apps are using the same mapping configuration.
> >>> >> >
> >>> >> > Do I need to use remote notification for this?
> >>> >> >
> >>> >> > thanks
> >>> >> >
> >>> >> > Tobias
> >>> >> >
> >>> >>
> >>> >
> >>>
> >>
> >
>

Re: sync cayenne cache in two web apps

Posted by Malcolm Edgar <ma...@gmail.com>.
You can also use OSCache with Cayenne and have the cached queries
expire frequently, i.e. after 30 seconds

regards Malcolm Edgar

On Thu, Jul 30, 2009 at 6:36 AM, Mike Kienenberger<mk...@gmail.com> wrote:
> Before you make your own custom solution, you might want to read up on
> Javagroup.  It might not be a problem to use it in your environment.
>
> The main page starts off with this:
>
> http://www.jgroups.org/
> ==================================
> JGroups is a toolkit for reliable multicast communication.
> (Note that this doesn't necessarily mean IP Multicast, JGroups can
> also use transports such as TCP).
>
> [...]
>
> JGroups comes with a number of protocols (but anyone can write their
> own), for example
>    * Transport protocols: UDP (IP Multicast), TCP, JMS
>
> ==================================
>
> So even if the TCP version doesn't do what you need, you might find it
> easier to write your own Jgroup protocol than to write your own
> cayenne event bridge.  It's more likely to be documented and there
> will be more examples/end users to ask questions of.  There might even
> be a tomcat shared session protocol out there somewhere.
>
>
> On Wed, Jul 29, 2009 at 4:16 PM, Tobias
> Schoessler<to...@gmail.com> wrote:
>> well i am reading this from the documentation:
>>
>> "... At the minimum, JMS setup requires a JMS server running, and subjects
>> for each of the DataDomains to be configured. JavaGroups is peer-to-peer
>> library that is embedded into applications. Default configuration provided
>> by CayenneModeler will work out of the box, provided that IP multicast is
>> enabled on the network."
>>
>> for the JMS solution the JMS server setup is a problem
>> for the JavaGroups setup the "IP multicast is enabled on the network."  is a
>> problem
>>
>> so  for the custom tranport mechanism that you mentioned I stumbled upon
>> this here
>>
>> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>>
>> which seems to describe cross context data sharing on tomcat web contexts
>>
>> but is there any code to look at to see how a custom transport mechanism can
>> be setup?
>>
>> Tobias
>>
>>
>> On Wed, Jul 29, 2009 at 8:28 PM, Mike Kienenberger <mk...@gmail.com>wrote:
>>
>>> I've never set it up, but it's easily configurable.
>>>
>>> If you don't like the javagroups or JMS methodologies, you can define
>>> your own -- I don't know what tomcat app-data-sharing ability is
>>> available -- it probably depends on the container, but I don't
>>> remember reading about any in the past.
>>>
>>> However, the docs seem to indicate that using Javagroups is pretty
>>> painless with no external configuration to deal with.
>>>
>>> I have a Cayenne 1.1.x application I wrote that used remote
>>> notification internally to broadcast events between sessions, so I
>>> know it's not difficult to set up and define your own event
>>> broadcaster.  My guess is that doing it for javagroups is pretty easy
>>> since it sounds like a matter of just filling in the forms on the
>>> modeler.
>>>
>>> On Wed, Jul 29, 2009 at 2:15 PM, Tobias
>>> Schoessler<to...@gmail.com> wrote:
>>> > Thanks Mike,
>>> >
>>> > so the answer is yes, this can only be done using remote notification? is
>>> > this correct?
>>> >
>>> > Isn't there a way to share the cache among two web application scopes
>>> > without going through the hassle of setting up remote notification?
>>> >
>>> > When the two webapps are running on the same physical machine, inside the
>>> > same application server this seems overkill.
>>> >
>>> > Tobias
>>> >
>>> > On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <mkienenb@gmail.com
>>> >wrote:
>>> >
>>> >> Yes,
>>> >>
>>> >> Here's a Cayenne 2.0 document on it:
>>> >>
>>> >> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
>>> >>
>>> >> For 3.0:
>>> >>
>>> >> http://cayenne.apache.org/doc/configuring-caching-behavior.html
>>> >>
>>> >> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
>>> >> Schoessler<to...@gmail.com> wrote:
>>> >> > Hi,
>>> >> >
>>> >> > is it possible to sync the cayenne cache of two web applications
>>> running
>>> >> in
>>> >> > the same tomcat?
>>> >> >
>>> >> > I observe one web app showing outdated data when the other is
>>> committing
>>> >> > updates. Both apps are using the same mapping configuration.
>>> >> >
>>> >> > Do I need to use remote notification for this?
>>> >> >
>>> >> > thanks
>>> >> >
>>> >> > Tobias
>>> >> >
>>> >>
>>> >
>>>
>>
>

Re: sync cayenne cache in two web apps

Posted by Mike Kienenberger <mk...@gmail.com>.
Before you make your own custom solution, you might want to read up on
Javagroup.  It might not be a problem to use it in your environment.

The main page starts off with this:

http://www.jgroups.org/
==================================
JGroups is a toolkit for reliable multicast communication.
(Note that this doesn't necessarily mean IP Multicast, JGroups can
also use transports such as TCP).

[...]

JGroups comes with a number of protocols (but anyone can write their
own), for example
    * Transport protocols: UDP (IP Multicast), TCP, JMS

==================================

So even if the TCP version doesn't do what you need, you might find it
easier to write your own Jgroup protocol than to write your own
cayenne event bridge.  It's more likely to be documented and there
will be more examples/end users to ask questions of.  There might even
be a tomcat shared session protocol out there somewhere.


On Wed, Jul 29, 2009 at 4:16 PM, Tobias
Schoessler<to...@gmail.com> wrote:
> well i am reading this from the documentation:
>
> "... At the minimum, JMS setup requires a JMS server running, and subjects
> for each of the DataDomains to be configured. JavaGroups is peer-to-peer
> library that is embedded into applications. Default configuration provided
> by CayenneModeler will work out of the box, provided that IP multicast is
> enabled on the network."
>
> for the JMS solution the JMS server setup is a problem
> for the JavaGroups setup the "IP multicast is enabled on the network."  is a
> problem
>
> so  for the custom tranport mechanism that you mentioned I stumbled upon
> this here
>
> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>
> which seems to describe cross context data sharing on tomcat web contexts
>
> but is there any code to look at to see how a custom transport mechanism can
> be setup?
>
> Tobias
>
>
> On Wed, Jul 29, 2009 at 8:28 PM, Mike Kienenberger <mk...@gmail.com>wrote:
>
>> I've never set it up, but it's easily configurable.
>>
>> If you don't like the javagroups or JMS methodologies, you can define
>> your own -- I don't know what tomcat app-data-sharing ability is
>> available -- it probably depends on the container, but I don't
>> remember reading about any in the past.
>>
>> However, the docs seem to indicate that using Javagroups is pretty
>> painless with no external configuration to deal with.
>>
>> I have a Cayenne 1.1.x application I wrote that used remote
>> notification internally to broadcast events between sessions, so I
>> know it's not difficult to set up and define your own event
>> broadcaster.  My guess is that doing it for javagroups is pretty easy
>> since it sounds like a matter of just filling in the forms on the
>> modeler.
>>
>> On Wed, Jul 29, 2009 at 2:15 PM, Tobias
>> Schoessler<to...@gmail.com> wrote:
>> > Thanks Mike,
>> >
>> > so the answer is yes, this can only be done using remote notification? is
>> > this correct?
>> >
>> > Isn't there a way to share the cache among two web application scopes
>> > without going through the hassle of setting up remote notification?
>> >
>> > When the two webapps are running on the same physical machine, inside the
>> > same application server this seems overkill.
>> >
>> > Tobias
>> >
>> > On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <mkienenb@gmail.com
>> >wrote:
>> >
>> >> Yes,
>> >>
>> >> Here's a Cayenne 2.0 document on it:
>> >>
>> >> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
>> >>
>> >> For 3.0:
>> >>
>> >> http://cayenne.apache.org/doc/configuring-caching-behavior.html
>> >>
>> >> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
>> >> Schoessler<to...@gmail.com> wrote:
>> >> > Hi,
>> >> >
>> >> > is it possible to sync the cayenne cache of two web applications
>> running
>> >> in
>> >> > the same tomcat?
>> >> >
>> >> > I observe one web app showing outdated data when the other is
>> committing
>> >> > updates. Both apps are using the same mapping configuration.
>> >> >
>> >> > Do I need to use remote notification for this?
>> >> >
>> >> > thanks
>> >> >
>> >> > Tobias
>> >> >
>> >>
>> >
>>
>

Re: sync cayenne cache in two web apps

Posted by Mike Kienenberger <mk...@gmail.com>.
Sorry.  I didn't see the part on multicasting.   After looking at that
article, I suppose you could try to share an actual datacontext, but
that's probably not realistic since few apps have only one
datacontext.

It'll be a bit more complicated, but you should be able to use a
custom EventBridge.

Here's how I set up an loopback event bridge under 1.1.x.  Things
might have changed a little bit, so I can't say for certain how
helpful this would be.  There's not much documentation, but it's
pretty straight-forward.

You'd want to extend it to transport the event somehow, perhaps by
queuing up an event in the shared session context, and then reading
the shared session context queue at the start of every request loop.
And you'll want to change it to ignore events sent by itself but not
by the other app.

In cayenne.xml:

<domain name="MyApp">
	<property name="cayenne.DataRowStore.remote.notify" value="true"/>
	<property name="cayenne.DataRowStore.EventBridge.factory"
value="com.xyz.cayenne.LocalEventBridgeFactory"/>



/*
 * Created on Dec 1, 2004
 */
package com.xyz.cayenne;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.objectstyle.cayenne.access.event.SnapshotEvent;
import org.objectstyle.cayenne.event.CayenneEvent;
import org.objectstyle.cayenne.event.EventBridge;
import org.objectstyle.cayenne.event.EventSubject;

/**
 * Class to automatically cause any snapshot changes for a particular
DataContext/DataRowStore to be broadcast to all other
DataContext/DataRowStores.
 */
public class LocalEventBridge extends EventBridge
{
	protected static Log log = LogFactory.getLog(LocalEventBridge.class);

    public LocalEventBridge(EventSubject localSubject, String externalSubject)
    {
        super(localSubject, externalSubject);
    }

    protected void startupExternal() throws Exception
    {
        // Do nothing
    }

    protected void shutdownExternal() throws Exception
    {
        // Do nothing
    }

    protected void sendExternalEvent(CayenneEvent localEvent) throws Exception
    {
        // Ignore events sent by all LocalEventBridges to prevent looping
        if (localEvent.getSource() instanceof LocalEventBridge)  return;

        if (localEvent instanceof SnapshotEvent)
        {
            // clone and post the event (source must be set to this
event bridge for our DataRowStore to receive it).
            SnapshotEvent snapshotEvent = (SnapshotEvent)localEvent;
            SnapshotEvent newSnapshotEvent = new SnapshotEvent(this,
snapshotEvent.getPostedBy(), snapshotEvent.getModifiedDiffs(),
snapshotEvent.getDeletedIds(), snapshotEvent.getInvalidatedIds(),
snapshotEvent.getIndirectlyModifiedIds());
            if (eventManager != null)
            {
                eventManager.postEvent(newSnapshotEvent, localSubject);
            }
            else {
                throw new IllegalStateException(
                    "Can't post events. EventBridge was not started properly. "
                        + "EventManager is null.");
            }
        }
    }
}


/*
 * Created on Dec 1, 2004
 */
package com.xyz.cayenne;

import java.util.Map;

import org.objectstyle.cayenne.event.EventBridge;
import org.objectstyle.cayenne.event.EventBridgeFactory;
import org.objectstyle.cayenne.event.EventSubject;

public class LocalEventBridgeFactory implements EventBridgeFactory
{
    public LocalEventBridgeFactory()
    {
        super();
    }

    public EventBridge createEventBridge(EventSubject localSubject,
            Map properties)
    {
        return new LocalEventBridge(localSubject,
EventBridge.convertToExternalSubject(localSubject));
    }
}

On Wed, Jul 29, 2009 at 4:16 PM, Tobias
Schoessler<to...@gmail.com> wrote:
> well i am reading this from the documentation:
>
> "... At the minimum, JMS setup requires a JMS server running, and subjects
> for each of the DataDomains to be configured. JavaGroups is peer-to-peer
> library that is embedded into applications. Default configuration provided
> by CayenneModeler will work out of the box, provided that IP multicast is
> enabled on the network."
>
> for the JMS solution the JMS server setup is a problem
> for the JavaGroups setup the "IP multicast is enabled on the network."  is a
> problem
>
> so  for the custom tranport mechanism that you mentioned I stumbled upon
> this here
>
> http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html
>
> which seems to describe cross context data sharing on tomcat web contexts
>
> but is there any code to look at to see how a custom transport mechanism can
> be setup?
>
> Tobias
>
>
> On Wed, Jul 29, 2009 at 8:28 PM, Mike Kienenberger <mk...@gmail.com>wrote:
>
>> I've never set it up, but it's easily configurable.
>>
>> If you don't like the javagroups or JMS methodologies, you can define
>> your own -- I don't know what tomcat app-data-sharing ability is
>> available -- it probably depends on the container, but I don't
>> remember reading about any in the past.
>>
>> However, the docs seem to indicate that using Javagroups is pretty
>> painless with no external configuration to deal with.
>>
>> I have a Cayenne 1.1.x application I wrote that used remote
>> notification internally to broadcast events between sessions, so I
>> know it's not difficult to set up and define your own event
>> broadcaster.  My guess is that doing it for javagroups is pretty easy
>> since it sounds like a matter of just filling in the forms on the
>> modeler.
>>
>> On Wed, Jul 29, 2009 at 2:15 PM, Tobias
>> Schoessler<to...@gmail.com> wrote:
>> > Thanks Mike,
>> >
>> > so the answer is yes, this can only be done using remote notification? is
>> > this correct?
>> >
>> > Isn't there a way to share the cache among two web application scopes
>> > without going through the hassle of setting up remote notification?
>> >
>> > When the two webapps are running on the same physical machine, inside the
>> > same application server this seems overkill.
>> >
>> > Tobias
>> >
>> > On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <mkienenb@gmail.com
>> >wrote:
>> >
>> >> Yes,
>> >>
>> >> Here's a Cayenne 2.0 document on it:
>> >>
>> >> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
>> >>
>> >> For 3.0:
>> >>
>> >> http://cayenne.apache.org/doc/configuring-caching-behavior.html
>> >>
>> >> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
>> >> Schoessler<to...@gmail.com> wrote:
>> >> > Hi,
>> >> >
>> >> > is it possible to sync the cayenne cache of two web applications
>> running
>> >> in
>> >> > the same tomcat?
>> >> >
>> >> > I observe one web app showing outdated data when the other is
>> committing
>> >> > updates. Both apps are using the same mapping configuration.
>> >> >
>> >> > Do I need to use remote notification for this?
>> >> >
>> >> > thanks
>> >> >
>> >> > Tobias
>> >> >
>> >>
>> >
>>
>

Re: sync cayenne cache in two web apps

Posted by Tobias Schoessler <to...@gmail.com>.
well i am reading this from the documentation:

"... At the minimum, JMS setup requires a JMS server running, and subjects
for each of the DataDomains to be configured. JavaGroups is peer-to-peer
library that is embedded into applications. Default configuration provided
by CayenneModeler will work out of the box, provided that IP multicast is
enabled on the network."

for the JMS solution the JMS server setup is a problem
for the JavaGroups setup the "IP multicast is enabled on the network."  is a
problem

so  for the custom tranport mechanism that you mentioned I stumbled upon
this here

http://jee-bpel-soa.blogspot.com/2009/06/session-sharing-in-apache-tomcat.html

which seems to describe cross context data sharing on tomcat web contexts

but is there any code to look at to see how a custom transport mechanism can
be setup?

Tobias


On Wed, Jul 29, 2009 at 8:28 PM, Mike Kienenberger <mk...@gmail.com>wrote:

> I've never set it up, but it's easily configurable.
>
> If you don't like the javagroups or JMS methodologies, you can define
> your own -- I don't know what tomcat app-data-sharing ability is
> available -- it probably depends on the container, but I don't
> remember reading about any in the past.
>
> However, the docs seem to indicate that using Javagroups is pretty
> painless with no external configuration to deal with.
>
> I have a Cayenne 1.1.x application I wrote that used remote
> notification internally to broadcast events between sessions, so I
> know it's not difficult to set up and define your own event
> broadcaster.  My guess is that doing it for javagroups is pretty easy
> since it sounds like a matter of just filling in the forms on the
> modeler.
>
> On Wed, Jul 29, 2009 at 2:15 PM, Tobias
> Schoessler<to...@gmail.com> wrote:
> > Thanks Mike,
> >
> > so the answer is yes, this can only be done using remote notification? is
> > this correct?
> >
> > Isn't there a way to share the cache among two web application scopes
> > without going through the hassle of setting up remote notification?
> >
> > When the two webapps are running on the same physical machine, inside the
> > same application server this seems overkill.
> >
> > Tobias
> >
> > On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <mkienenb@gmail.com
> >wrote:
> >
> >> Yes,
> >>
> >> Here's a Cayenne 2.0 document on it:
> >>
> >> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
> >>
> >> For 3.0:
> >>
> >> http://cayenne.apache.org/doc/configuring-caching-behavior.html
> >>
> >> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
> >> Schoessler<to...@gmail.com> wrote:
> >> > Hi,
> >> >
> >> > is it possible to sync the cayenne cache of two web applications
> running
> >> in
> >> > the same tomcat?
> >> >
> >> > I observe one web app showing outdated data when the other is
> committing
> >> > updates. Both apps are using the same mapping configuration.
> >> >
> >> > Do I need to use remote notification for this?
> >> >
> >> > thanks
> >> >
> >> > Tobias
> >> >
> >>
> >
>

Re: sync cayenne cache in two web apps

Posted by Mike Kienenberger <mk...@gmail.com>.
I've never set it up, but it's easily configurable.

If you don't like the javagroups or JMS methodologies, you can define
your own -- I don't know what tomcat app-data-sharing ability is
available -- it probably depends on the container, but I don't
remember reading about any in the past.

However, the docs seem to indicate that using Javagroups is pretty
painless with no external configuration to deal with.

I have a Cayenne 1.1.x application I wrote that used remote
notification internally to broadcast events between sessions, so I
know it's not difficult to set up and define your own event
broadcaster.  My guess is that doing it for javagroups is pretty easy
since it sounds like a matter of just filling in the forms on the
modeler.

On Wed, Jul 29, 2009 at 2:15 PM, Tobias
Schoessler<to...@gmail.com> wrote:
> Thanks Mike,
>
> so the answer is yes, this can only be done using remote notification? is
> this correct?
>
> Isn't there a way to share the cache among two web application scopes
> without going through the hassle of setting up remote notification?
>
> When the two webapps are running on the same physical machine, inside the
> same application server this seems overkill.
>
> Tobias
>
> On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <mk...@gmail.com>wrote:
>
>> Yes,
>>
>> Here's a Cayenne 2.0 document on it:
>>
>> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
>>
>> For 3.0:
>>
>> http://cayenne.apache.org/doc/configuring-caching-behavior.html
>>
>> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
>> Schoessler<to...@gmail.com> wrote:
>> > Hi,
>> >
>> > is it possible to sync the cayenne cache of two web applications running
>> in
>> > the same tomcat?
>> >
>> > I observe one web app showing outdated data when the other is committing
>> > updates. Both apps are using the same mapping configuration.
>> >
>> > Do I need to use remote notification for this?
>> >
>> > thanks
>> >
>> > Tobias
>> >
>>
>

Re: sync cayenne cache in two web apps

Posted by Tobias Schoessler <to...@gmail.com>.
Thanks Mike,

so the answer is yes, this can only be done using remote notification? is
this correct?

Isn't there a way to share the cache among two web application scopes
without going through the hassle of setting up remote notification?

When the two webapps are running on the same physical machine, inside the
same application server this seems overkill.

Tobias

On Wed, Jul 29, 2009 at 6:50 PM, Mike Kienenberger <mk...@gmail.com>wrote:

> Yes,
>
> Here's a Cayenne 2.0 document on it:
>
> http://cayenne.apache.org/doc20/configuring-caching-behavior.html
>
> For 3.0:
>
> http://cayenne.apache.org/doc/configuring-caching-behavior.html
>
> On Wed, Jul 29, 2009 at 12:46 PM, Tobias
> Schoessler<to...@gmail.com> wrote:
> > Hi,
> >
> > is it possible to sync the cayenne cache of two web applications running
> in
> > the same tomcat?
> >
> > I observe one web app showing outdated data when the other is committing
> > updates. Both apps are using the same mapping configuration.
> >
> > Do I need to use remote notification for this?
> >
> > thanks
> >
> > Tobias
> >
>

Re: sync cayenne cache in two web apps

Posted by Mike Kienenberger <mk...@gmail.com>.
Yes,

Here's a Cayenne 2.0 document on it:

http://cayenne.apache.org/doc20/configuring-caching-behavior.html

For 3.0:

http://cayenne.apache.org/doc/configuring-caching-behavior.html

On Wed, Jul 29, 2009 at 12:46 PM, Tobias
Schoessler<to...@gmail.com> wrote:
> Hi,
>
> is it possible to sync the cayenne cache of two web applications running in
> the same tomcat?
>
> I observe one web app showing outdated data when the other is committing
> updates. Both apps are using the same mapping configuration.
>
> Do I need to use remote notification for this?
>
> thanks
>
> Tobias
>