camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Piotr Klimczak (JIRA)" <j...@apache.org>
Subject [jira] [Issue Comment Edited] (CAMEL-3686) Allow to share cache between bundles, and only clear cache when no more bundles access that cache
Date Fri, 10 Jun 2011 14:52:59 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-3686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13047229#comment-13047229
] 

Piotr Klimczak edited comment on CAMEL-3686 at 6/10/11 2:51 PM:
----------------------------------------------------------------

Sorry for late answer but i haven't received email notification about your post.
So if you set your cache to be shared, then the cache manager will not be stopped during bundle
shutdown. You have to care care about closing cacheManager by your self. This is because cache
manager have to be shared across bundles as an osgi service.

It is a bit complicated. Let's take a look at simple example.
Let's say we have 3 bundles:
a) the one which instantiates cacheManagerFactory and exposes it as an osgi service
b) the first one, which uses exposed by bundle a) cacheManagerFactory and uses it's cacheManager
in it's own cacheManagerFactory (as shown in above example: YourCacheManagerFactory)
c) the second one, same as b)

So b) and c) uses shared cacheManager of bundle a) and both are marked as shared. Thanks to
this cacheManager is not closed during b) or c) shutdown.
BUT if you shutdown the a) bundle, then all caches used by b) and c) may gone (dependently
on your cacheManagerFactory implementation in bundle a)).

This is how it suppose to work, but was not tested in full scenario yet. Only partially by
some unit tests.
Please let me know if something is wrong with my idea.
Better ideas are welcome! :)

      was (Author: nannou9):
    Sorry for late answer but i haven't received email notification about your post.
So if you set your cache to be shared, then the cache manager will not be stopped during bundle
shutdown. You have to care care about closing cacheManager by your self. This is because cache
manager have to be shared across bundles as an osgi service.

It is a bit complicated. Let's take a look at simple example.
Let's say we have 3 bundles:
a) the one which instantiates cacheManagerFactory and exposes it as an osgi service
b) the first one, which uses exposed by bundle a) cacheManagerFactory and uses it's cacheManager
in it's own cacheManagerFactory (as shown in above example: YourCacheManagerFactory)
c) the second one, same as b)

So b) and c) uses shared cacheManager of bundle a) and both are marked as shared. And because
of cache manager is not closed during b) or c) shutdown.
BUT if you shutdown the a) bundle, then all caches used by b) and c) are gone.

This is how it suppose to work, but was not tested in full scenario yet. Only partially by
some unit tests.
Please let me know if something is wrong with my idea.
Better ideas are welcome! :)
  
> Allow to share cache between bundles, and only clear cache when no more bundles access
that cache
> -------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3686
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3686
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-cache
>    Affects Versions: 2.4.0
>         Environment: camel-cache 2.4.0-fuse-01-00
>            Reporter: Justas
>             Fix For: 2.9.0
>
>         Attachments: camel-cache.shared.patch, camel-cache.zip, diff.txt
>
>
> I am using camel-cache component in serviceMix. Cache endpoint uri is 
> "cache://elements?maxElementsInMemory=2&memoryStoreEvictionPolicy=MemoryStoreEvictionPolicy.FIFO&overflowToDisk=false&eternal=false&timeToLiveSeconds=800"

> I have 2 bundles (core.jar, services.jar). Inside those bundles I use 
> @EndpointInject(uri = Constants.CACHE_URI) 
> ProducerTemplate cacheTemplate; 
> cacheTemplate.requestBodyAndHeaders(...) 
> core.jar puts and reads elements from cache. 
> services.jar only reads elements from cache. 
> After deploying both bundles it works fine, but if i uninstall services.jar, cache is
"destroyed". core.jar (and all others) can't put objects into cache anymore. 
> How could I make all bundles to "share" the same cache? 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message