aspose file tools
The moose likes EJB and Other Java EE Technologies and the fly likes sharing MAP on MDB pool Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » EJB and Other Java EE Technologies
Reply Bookmark "sharing MAP on MDB pool" Watch "sharing MAP on MDB pool" New topic
Author

sharing MAP on MDB pool

domenico febbo
Greenhorn

Joined: Mar 24, 2009
Posts: 4
Hi all,
I need to share a ConcurrentHashMap Map (from the Collection Framework) between a pool of MDBs.
What is the best practice?
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

If your application is in a cluster or will move to a cluster, think of db or serialized objects (or any persistent store).
If it's readonly and not in a cluster, you can use a static variable.

ram.
domenico febbo
Greenhorn

Joined: Mar 24, 2009
Posts: 4
ramprasad madathil wrote:If your application is in a cluster or will move to a cluster, think of db or serialized objects (or any persistent store).
If it's readonly and not in a cluster, you can use a static variable.

ram.


Thanks,
It will be in cluster and not read-only, but I don't want to use DB or persistent because of some other constraint, so
1) how can I use serialized object?
2) there is a chance to use a Session EJB accessible vie JNDI lookup?

ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

how can I use serialized object?


I dont think it's a great idea. Basically you create an object on first access and write it to a shared file system storage. Every time, you retrieve it, change the values and write it back. You will have to write custom code to ensure locking etc (to prevent concurrency) which is the same challenge you would face if you use static in a non-clustered environment.

there is a chance to use a Session EJB accessible vie JNDI lookup?


And store the data in the session ejb - a stateful session ejb? I really dont know - you will have to find answer to the same challenges of multithreading etc.

Google for cluster aware cache (or ditributed cache) - there is one here - http://www.opensymphony.com/oscache/wiki/Clustering.html

ram.


 
 
subject: sharing MAP on MDB pool
 
MyEclipse, The Clear Choice