简体   繁体   English

是否可以从两个不同的Java应用程序访问同一Ehcache对象?

[英]Is it possible to access the same Ehcache object from two different java applications?

I have two Java applications. 我有两个Java应用程序。

One is a jar file that executes and writes certain data to the EhCache. 一个是执行并向EhCache写入某些数据的jar文件。

The another application is installed as a war on weblogic server. 在Weblogic服务器上安装了另一个应用程序作为战争。

My question is that is there any way to access the same Ehcache object that was written by the jar file from the war application and retrieve the data from it? 我的问题是,有什么方法可以访问战争应用程序中jar文件编写的同一个Ehcache对象,并从中检索数据?

The weblogic and the jar file are on the same machine. weblogic和jar文件位于同一台计算机上。

Any help would be appreciated. 任何帮助,将不胜感激。 Thanx. 谢谢

The short answer is : Yes, possible but not straightforward, you will need some work. 简短的答案是:是的,可能但不直接,您需要做一些工作。

What you are looking for in your case is cache replication, check out details here 您要寻找的是缓存复制, 请在此处查看详细信息

If both the applications one in your JAR file and the one in WAR file are running constantly and synchronously (ie only one of them will NOT be down at any given point) then RMI can be your choice. 如果JAR文件中的一个应用程序和WAR文件中的一个应用程序都持续且同步运行(即,在给定的时间点只有一个应用程序不会关闭),则可以选择RMI。 If one of application is expected to be down while other is up, then you will need to hold the cache object/data somewhere and JMS is one of natural choices. 如果一个应用程序预计将关闭而另一个应用程序处于启动,那么您将需要将缓存对象/数据保存在某处,而JMS是自然的选择之一。 If they are on same machine or not does not really matter. 它们是否在同一台计算机上并不重要。

What you are basically wanting to do is JVM to JVM communication - and it can be for any object not necessarily for Ehcache. 您基本上想要做的是JVM与JVM之间的通信-它可以用于任何对象,而不必用于Ehcache。 Some of other options are discussed here 这里讨论了其他一些选项

Understand that the "Objects" in a JVM are temporary and will die when they are no longer referenced or when JVM dies. 了解JVM中的“对象”是临时的,并且在不再引用它们或JVM死亡时将消失。 Anytime you want them to be transported outside JVM, you will need to write in some hard medium like File, A message or transport them over mechanisms like RMI or a service call. 每当您希望将它们传输到JVM之外时,都需要在某种硬介质(例如文件,消息)中进行写入,或者通过RMI或服务调用之类的机制进行传输。 While transporting there, you will need to convert the object in a language which the target understands - which is basically marshalling and un-marshalling or serialization and de-serialization. 在将其传输到那里时,您将需要使用目标可以理解的语言来转换对象-这基本上是编组和解组或序列化和反序列化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java:从同一个JAR启动两个不同的应用程序吗? - Java: launch two different applications from the same JAR? 可以使用两个线程访问LinkedList中同一对象的不同属性吗? - Possible to access to different attributes of the same object in a LinkedList using two Threads? 两个不同的Java应用程序共享同一个数据库 - Two different Java applications sharing the same database Java CardLayout:是否可以在两张不同的卡上使用相同的对象? - Java CardLayout: Is it possible to use same object on two different cards? 如何在Java中同时访问同一对象的两种不同方法? - How to access two different methods of the same object concurrently in Java? 是否可以从两个不同的Servlet同时访问同一个DB? - Is it possible to access concurrently to the same DB from two different Servlets? 可以同时使用 Java 7 和 Java 8 和两个不同的应用程序吗? - Working with Java 7 and Java 8 with two different applications at time is possible? 从2个不同的war文件中访问相同的ehcache - Accessing same ehcache from 2 different war files 使用Ehcache扩展Java Web应用程序 - Scaling Java web applications with Ehcache 是否可以使用多个ehcache.xml(在不同的项目中,同样的战争)? - Is it possible to use multiple ehcache.xml (in different projects, same war)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM