4

Do you know of a Java EE compliant way to hold data (let's say a couple of key-value pairs) in a Java EE application without using a database? The solution should be usable in a cluster. I know about the concepts of data grids (e.g. Infinispan in JBoss), but i'd prefer a solution where the application does not depend on a specific application server (JCache would be great, for example, but as far i understood it, that is only usable as local cache with Infinispan, not as distributed cache).

So is it possible, for example, to save data somehow with CDI (maybe in context @ApplicationScoped)? If yes, could you describe, how?

EDIT: Thank you for all your answers. All of them right now recommend me to use certain frameworks. But isn't there a way just with the Java EE stack to do sth. like this?

Daniel Nuss
  • 341
  • 3
  • 15

5 Answers5

1

If I understand your use case correctly, this is doable with Infinispan and additionally this is one of the basic Infinispan usages. Your application will not depend on any application server while using embedded libraries and Infinispan is capable of creating cluster in that embedded mode.

Please, see this question and my answer to it, I hope this can help and put some light on your question as well: Infinispan Operational modes

Community
  • 1
  • 1
tsykora
  • 723
  • 1
  • 8
  • 19
  • Thank you for your answer. I have no doubt that i can do that with Infinispan. In fact, my application is already deployed on JBoss and i use Infinispan (the embedded one in JBoss) for a certain scenario in a cluster environment, which works well. But the same application has to be able to run on Websphere one day, which is the reason i want to build a portable solution. It just seems a bit strange to me to use Infinispan in that case, as WAS has its own data grid. In what way would you recommend to use it then anyway? As standalone server or deployed as JCA connector/packaged within my ear? – Daniel Nuss Oct 31 '13 at 11:19
  • I am not a solution architect but I believe you should left embedded Infinispan libraries in JBoss and migrate to the latest publicly available Infinispan upstream version (http://infinispan.org/download/) and use these libraries. Then, it doesn't matter which application server you are using for your applications and you should be able to use in-memory Infinispan clustering even with Websphere, because Infinispan functionality is bound to your application, not to the app server. Do I understand it correctly? Are there any specific issues? – tsykora Oct 31 '13 at 11:27
  • Well... i don't know for sure but i don't think it is a JEE compliant way. I am not allowed to open threads or ports by myself in an JEE application according to the specifications, because these things should be managed by the container. And to my understanding, i had to do sth. like this when configuring an Infinispan which runs embedded in my application, don't i? – Daniel Nuss Oct 31 '13 at 13:13
  • From my point of view: You need to ensure flawless JGroups communication in order to make nodes in a cluster see each other. It may need some open ports, etc. But, still, this is the main use case of Infinispan and I can't understand how this can violate JEE specification. It was designed for that. I'm sorry for my lack of knowledge. If you need some help from developers, ask on jboss.org forum or join our #infinispan channel on freenode, IRC. Devs are more responsive there than on SO. – tsykora Nov 02 '13 at 08:03
0

I think what you are searching for are called in-memory data grids. Take a look on Hazelcast for example.

You should be careful though and store data explicitly if it is important (most of the time these are used for boost caching).

rlegendi
  • 10,466
  • 3
  • 38
  • 50
0

I don't know the terms even in the question. But, What about using XML as data store?
This can be shared as well.

Chowdappa
  • 1,580
  • 1
  • 15
  • 31
0

I think it is possible with Oracle Coherence API

Ahmet Karakaya
  • 9,899
  • 23
  • 86
  • 141
-1

Try Using Bigmemory from Terracotta, which provides in memory data caching, and performs great in clustered world.

  • Caching is not saving. BTW, nice username compared to the content of your 'answer'. –  Oct 31 '13 at 13:14